home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume25 / trn / part02 < prev    next >
Encoding:
Internet Message Format  |  1991-12-02  |  85.3 KB

  1. Subject:  v25i005:  trn 2.0 - threaded newsreader based on rn 4.4, Part02/13
  2. Newsgroups: comp.sources.unix
  3. Approved: vixie@pa.dec.com
  4.  
  5. Submitted-by: davison@borland.com (Wayne Davison)
  6. Posting-number: Volume 25, Issue 5
  7. Archive-name: trn/part02
  8.  
  9. #! /bin/sh
  10. # This is a shell archive.  Remove anything before this line, then unpack
  11. # it by saving it into a file and typing "sh file".  To overwrite existing
  12. # files, type "sh file -c".  You can also feed this as standard input via
  13. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  14. # will see the following message at the end:
  15. #        "End of archive 2 (of 13)."
  16. # Contents:  HACKERSGUIDE HINTS Pnews.1 Rnmail.1 artio.c backpage.c
  17. #   bits.h cheat.c getactive.c head.h last.c makedepend.SH mt-misc.c
  18. #   ndir.c ndir.h.SH newsetup.1 newsetup.SH newsgroups.1 newsgroups.SH
  19. #   newsnews.SH ngsrch.c only.c rcstuff.h threads.c
  20. # Wrapped by vixie@cognition.pa.dec.com on Tue Dec  3 16:34:51 1991
  21. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  22. if test -f 'HACKERSGUIDE' -a "${1}" != "-c" ; then 
  23.   echo shar: Will not clobber existing file \"'HACKERSGUIDE'\"
  24. else
  25. echo shar: Extracting \"'HACKERSGUIDE'\" \(4519 characters\)
  26. sed "s/^X//" >'HACKERSGUIDE' <<'END_OF_FILE'
  27. Hacking Notes
  28. X
  29. If you aren't interested in mucking with the innards of rn, don't read this.
  30. X
  31. In the interests of both space and time optimization, things are done inside
  32. rn that don't always conform to the highest ideals of programming.  To the
  33. extent I felt it was practical, I've tried to conform to good programming
  34. practice, but you must realize that my goal was to make a better mousetrap,
  35. so certain conscious tradeoffs were made in the design of rn right from the
  36. start.  In particular, if you want to hack on rn (and I wouldn't blame you,
  37. it's fun), beware of the following:
  38. X  
  39. X  * buf and cmd_buf are reused all over the place.  11-squishing is a good
  40. X    term for it.  No, I'm on a Vax now, but I've been there.
  41. X
  42. X  * The article header is parsed on the fly, while it is being displayed.
  43. X    In fact, practically everything is done on the fly within the article
  44. X    display loop, and there are plenty of state variables.  The header
  45. X    is never explicitly stored in memory; rather, pointers are kept into
  46. X    the file.  The information required to backup pages is not stored in
  47. X    memory, except for 1 buffer's worth.  The information required to do
  48. X    the delayed mark as unread (M) is not stored in memory either.
  49. X
  50. X  * Lots of contortions are gone through to avoid using static memory, or
  51. X    allocating unnecessary memory, or losing track of allocated memory,
  52. X    while at the same time allowing .newsrc lines and header lines to be
  53. X    ANY length up to the amount of memory you have.  Rn spends a great deal
  54. X    of effort being lazy.  Do not use a static buffer when you can use
  55. X    growstr(). 
  56. X
  57. X  * Lots of contortions are gone through to try to do things when people
  58. X    aren't waiting, or have only been waiting a very short time.  Guessing
  59. X    the next article to be opened and opening it, searching ahead for the
  60. X    next article with the same subject, delaying the look up of the number
  61. X    of articles in a newsgroup, writing the rest of the page while the
  62. X    reader is examining the header, cacheing up subjects while the user
  63. X    is reading, checkpointing the .newsrc only while the reader is in the
  64. X    middle of an interesting article, are some of the strategies employed.
  65. X  
  66. X  * There are plenty of goto's.  Most of them involve going back to reprompt,
  67. X    to reask for input, or to just plain do the unstructured things people
  68. X    want to do when they are glaring at a terminal.  If they bother you
  69. X    too much, just think of rn as a big state machine.  If they don't bother
  70. X    you at all, I don't want you hacking on rn.
  71. X
  72. X  * Put all includes at the front of the file, before the first function,
  73. X    or makedepend will not work right.  I could relax this, but makedepend
  74. X    would take about 5 times longer to run.
  75. X
  76. In general then, feel free to hack on rn.  Just don't broadcast untested
  77. patches to the net.  Remember that there are people with limited address
  78. spaces and limited cpu cycles.  If you add a wonderful new feature and
  79. want to publish a patch, put #ifdef's around it so that people who don't
  80. want it or can't afford it can work around it.  THIS MEANS YOU.  We don't
  81. need 57 varieties of mutually incompatible and incomprehensible rn floating
  82. about the net.  Consider telling me about your patch so that I can consider
  83. including it in the standard version.  A COMPLETE PATCH TAKES INTO ACCOUNT
  84. SYSTEM DEPENDENCIES AS DETERMINED BY THE CONFIGURE SCRIPT.
  85. X
  86. X* Don't use ints where rn uses typedefs, in particular, for article numbers.
  87. X* Don't use %d anywhere that someone might need a %ld.  (Just because YOU
  88. X    typedefed it as an int doesn't mean someone else won't need a long.)
  89. X* Don't use %D, that's archaic.
  90. X* Put FLUSHes after printf()s, fputs()es and putchar('\n')s for our poor
  91. X    brethern and sistern without line buffering.
  92. X* Declare the type of every function.  Use void, even if your C compiler
  93. X    doesn't.
  94. X* Follow the style that rn already uses!  This is my pet peeve.  Well, one of
  95. X    them, anyway.  I follow other people's strange styles when modifying
  96. X    their programs, so I'd be much obliged if you did likewise.
  97. X* Use lint.
  98. X* Use RCS.  Start a new branch, like 4.4.[2-9].  (I will use 4.4.1 myself.)
  99. X* Be structured wherever it doesn't interfere with practicality.
  100. X* Long live paranoid programming.  The rest of the program is out to get you.
  101. X    The world is out to destroy the program, not to mention the .newsrc.
  102. X    And then there's always bitrot...
  103. X* Stop reading this lugubrious trash and start thinking for yourself.
  104. X* Thank you and good night.
  105. END_OF_FILE
  106. if test 4519 -ne `wc -c <'HACKERSGUIDE'`; then
  107.     echo shar: \"'HACKERSGUIDE'\" unpacked with wrong size!
  108. fi
  109. # end of 'HACKERSGUIDE'
  110. fi
  111. if test -f 'HINTS' -a "${1}" != "-c" ; then 
  112.   echo shar: Will not clobber existing file \"'HINTS'\"
  113. else
  114. echo shar: Extracting \"'HINTS'\" \(2647 characters\)
  115. sed "s/^X//" >'HINTS' <<'END_OF_FILE'
  116. Here's some helpful hints for getting the most out of trn:
  117. X
  118. The 'X' command in the thread selector (kinda like catchup/yes) can be made
  119. the default action on the last page of selections by using the command-line
  120. option:  -XX.  This lets you browse all the pages, making selections as you
  121. go, and then mark everything that was not selected as read when you press
  122. space at the last page.
  123. X----------
  124. If you like to select a little, read a little, and then select a little more,
  125. try using the command-line option:  -XDD.  This makes the 'D' command the
  126. default on all pages of the thread selector.  Thus you can select the things
  127. you want to read on the current page, press space, and you will read the
  128. selected articles immediately (if there were any).  All other articles on the
  129. current page will be marked as read.  (Don't use -XXD, because new articles
  130. might have arrived while reading, and they could be marked as read without
  131. ever seeing them.)
  132. X----------
  133. I like to use the -xls command-line option to only have the long and short
  134. modes in the thread selector (leaving out the mid-sized one).  Press 'L' to
  135. switch modes.
  136. X----------
  137. Keep in mind that you can create a file called .trninit and point trn at
  138. it by definining the environment variable TRNINIT.  Depending on your shell,
  139. you might use "setenv TRNINIT ~/.trninit" or some other type of assignment
  140. X(put the definition in your shell's rc file).  Then put all your command-line
  141. options in this file.
  142. X----------
  143. I like to redefine the 'u' keys in the following way:  'u' visits the "Set
  144. unread?" prompt (except at the thread selector), 'U' goes directly to the
  145. already-read article selector, and Ctrl-U unsubscribes from the group (even
  146. while in the thread selector).  Put the following 3 macros in your .trninit
  147. file to accomplish this:
  148. X
  149. u    %(%m=[anp]?U:u)
  150. U    %(%m=[anp]?U+:U)
  151. X^U    %(%m=t?+u:u)
  152. X----------
  153. If you like the way that 'q' worked in the thread selector in trn 1.x, put
  154. the following macro in your .trninit file:
  155. X
  156. q    %(%m=t?+:q)
  157. X----------
  158. If you want to be able to save your shar headers in a file as they are
  159. extracted and you have access to "unshar" (a program that can extract
  160. shar files while saving the headers in UNSHAR.HDR), twiddle the external
  161. extract command to send the entire article:
  162. X
  163. X        (regular)                          (nntp)
  164. X-EEXSAVER="%e <%A"               -EEXSAVER "%e <%P/rrn%a.%$"
  165. X
  166. and then point the UNSHAR variable at unshar instead of /bin/sh:
  167. X
  168. X-EUNSHAR="unshar -s"
  169. X
  170. Note that this assumes that any other commands you execute with "e dir|command"
  171. can also handle the entire article as input (uuencoded and shipped files are
  172. not affected).
  173. X----------
  174. END_OF_FILE
  175. if test 2647 -ne `wc -c <'HINTS'`; then
  176.     echo shar: \"'HINTS'\" unpacked with wrong size!
  177. fi
  178. # end of 'HINTS'
  179. fi
  180. if test -f 'Pnews.1' -a "${1}" != "-c" ; then 
  181.   echo shar: Will not clobber existing file \"'Pnews.1'\"
  182. else
  183. echo shar: Extracting \"'Pnews.1'\" \(3869 characters\)
  184. sed "s/^X//" >'Pnews.1' <<'END_OF_FILE'
  185. X.\" $Id: Pnews.1,v 4.4.1.1 1991/09/25 19:36:48 sob Exp sob $
  186. X.\" 
  187. X.\" $Log: Pnews.1,v $
  188. X.\" Revision 4.4.1.1  1991/09/25  19:36:48  sob
  189. X.\" Changed quote macro to "standard" one
  190. X.\"
  191. X.\" Revision 4.4  1991/09/09  20:18:23  sob
  192. X.\" release 4.4
  193. X.\"
  194. X.\" 
  195. X.\" This software is Copyright 1991 by Stan Barber. 
  196. X.\"
  197. X.\" Permission is hereby granted to copy, reproduce, redistribute or otherwise
  198. X.\" use this software as long as: there is no monetary profit gained
  199. X.\" specifically from the use or reproduction of this software, it is not
  200. X.\" sold, rented, traded or otherwise marketed, and this copyright notice is
  201. X.\" included prominently in any copy made. 
  202. X.\"
  203. X.\" The author make no claims as to the fitness or correctness of this software
  204. X.\" for any use whatsoever, and it is provided as is. Any use of this software
  205. X.\" is at the user's own risk. 
  206. X.\"
  207. X.de Sh
  208. X.br
  209. X.ne 5
  210. X.PP
  211. X\fB\\$1\fR
  212. X.PP
  213. X..
  214. X.de Sp
  215. X.if t .sp .5v
  216. X.if n .sp
  217. X..
  218. X.\"
  219. X.\"     Set up \*(-- to give an unbreakable dash;
  220. X.\"     string Tr holds user defined translation string.
  221. X.\"     Bell System Logo is used as a dummy character.
  222. X.\"
  223. X.ie n \{\
  224. X.tr \(bs-\*(Tr
  225. X.ds -- \(bs-
  226. X.if (\n(.H=4u)&(1m=24u) .ds -- \(bs\h'-12u'\(bs\h'-12u'-\" diablo 10 pitch
  227. X.if (\n(.H=4u)&(1m=20u) .ds -- \(bs\h'-12u'\(bs\h'-8u'-\" diablo 12 pitch
  228. X.ds L" ""
  229. X.ds R" ""
  230. X.ds L' '
  231. X.ds R' '
  232. X'br\}
  233. X.el\{\
  234. X.ds -- \(em\|
  235. X.tr \*(Tr
  236. X.ds L" ``
  237. X.ds R" ''
  238. X.ds L' `
  239. X.ds R' '
  240. X'br\}
  241. X.TH PNEWS 1 LOCAL
  242. X.SH NAME
  243. Pnews - a program for posting news articles
  244. X.SH SYNOPSIS
  245. X.B Pnews newsgroup title
  246. X.br
  247. X  or
  248. X.br
  249. X.B Pnews -h headerfile [oldarticle]
  250. X.br
  251. X  or
  252. X.br
  253. X.B Pnews
  254. X.SH DESCRIPTION
  255. Pnews is a friendly interface for posting news articles.
  256. It will ask several questions, then allow you to enter your article,
  257. and then post it using the inews(1) program.
  258. If you type h and a carriage return at any point,
  259. X.I Pnews
  260. will tell you what it wants to know.
  261. X.PP
  262. The -h form is used when invoked from
  263. X.IR rn .
  264. If your editor can edit multiple files, and you want the article to which
  265. you are replying to show up as an alternate file, define the environment
  266. variable NEWSPOSTER as \*(L"Pnews -h %h %A\*(R".
  267. You can also modify the the NEWSHEADER environment variable to change the
  268. header file that
  269. X.I rn
  270. passes to Pnews.
  271. X.SH ENVIRONMENT
  272. X.IP AUTHORCOPY 8
  273. If defined, contains the name of a file to which the finished article will
  274. be appended.
  275. X.Sp
  276. Default: article not saved
  277. X.IP DOTDIR 8
  278. Where to find your dot files, if they aren't in your home directory.
  279. This is primarily for accounts which are shared by more than one person.
  280. X.Sp
  281. Default: $HOME
  282. X.IP EDITOR 8
  283. The editor you want to use, if VISUAL is undefined.
  284. X.Sp
  285. Default: whatever your news administrator installed, usually vi.
  286. X.IP HOME 8
  287. Your home directory.
  288. X.Sp
  289. Default: $LOGDIR
  290. X.IP LOGDIR 8
  291. Your home directory if HOME is undefined.
  292. X.IP LOGNAME 8
  293. Your login name, if USER is undefined.
  294. X.Sp
  295. Default: value of \*(L"whoami\*(R".
  296. X.IP NAME 8
  297. Your full name.
  298. X.Sp
  299. Default: name from /etc/passwd, or ~/.fullname.
  300. X.IP NEWSORG 8
  301. XEither the name of your organization, or the name of a file containing the
  302. name of your organization. (For use at organizations where the ORGANIZATION
  303. environmental variable is in use for other purposes). If both NEWSORG and
  304. ORGANIZATION are set, NEWSORG will override ORGANIZATION.
  305. X.IP ORGANIZATION 8
  306. XEither the name of your organization, or the name of a file containing the
  307. name of your organization.
  308. X.Sp
  309. Default: whatever your news administrator chose.
  310. X.IP REPLYTO 8
  311. The contents of a \*(L"Reply-To:\*(R" header line to insert into your message.
  312. X.Sp
  313. Default: header line not inserted.
  314. X.IP USER 8
  315. Your login name.
  316. X.Sp
  317. Default: $LOGNAME
  318. X.IP VISUAL 8
  319. The editor you want to use.
  320. X.Sp
  321. Default: $EDITOR
  322. X.SH FILES
  323. X$DOTDIR/.article
  324. X.br
  325. X~/dead.article
  326. X.SH SEE ALSO
  327. rn(1), Rnmail(1), inews(1)
  328. X.SH DIAGNOSTICS
  329. X.SH BUGS
  330. Not the speediest program in the world, but maybe that's a blessing to the
  331. net.
  332. END_OF_FILE
  333. if test 3869 -ne `wc -c <'Pnews.1'`; then
  334.     echo shar: \"'Pnews.1'\" unpacked with wrong size!
  335. fi
  336. # end of 'Pnews.1'
  337. fi
  338. if test -f 'Rnmail.1' -a "${1}" != "-c" ; then 
  339.   echo shar: Will not clobber existing file \"'Rnmail.1'\"
  340. else
  341. echo shar: Extracting \"'Rnmail.1'\" \(3823 characters\)
  342. sed "s/^X//" >'Rnmail.1' <<'END_OF_FILE'
  343. X.\" $Id: Rnmail.1,v 4.4.1.1 1991/09/25 19:36:48 sob Exp sob $
  344. X.\" 
  345. X.\" $Log: Rnmail.1,v $
  346. X.\" Revision 4.4.1.1  1991/09/25  19:36:48  sob
  347. X.\" Changed quote macro to "standard" one
  348. X.\"
  349. X.\" Revision 4.4  1991/09/09  20:18:23  sob
  350. X.\" release 4.4
  351. X.\"
  352. X.\" 
  353. X.\" This software is Copyright 1991 by Stan Barber. 
  354. X.\"
  355. X.\" Permission is hereby granted to copy, reproduce, redistribute or otherwise
  356. X.\" use this software as long as: there is no monetary profit gained
  357. X.\" specifically from the use or reproduction of this software, it is not
  358. X.\" sold, rented, traded or otherwise marketed, and this copyright notice is
  359. X.\" included prominently in any copy made. 
  360. X.\"
  361. X.\" The author make no claims as to the fitness or correctness of this software
  362. X.\" for any use whatsoever, and it is provided as is. Any use of this software
  363. X.\" is at the user's own risk. 
  364. X.\"
  365. X.de Sh
  366. X.br
  367. X.ne 5
  368. X.PP
  369. X\fB\\$1\fR
  370. X.PP
  371. X..
  372. X.de Sp
  373. X.if t .sp .5v
  374. X.if n .sp
  375. X..
  376. X.\"
  377. X.\"     Set up \*(-- to give an unbreakable dash;
  378. X.\"     string Tr holds user defined translation string.
  379. X.\"     Bell System Logo is used as a dummy character.
  380. X.\"
  381. X.ie n \{\
  382. X.tr \(bs-\*(Tr
  383. X.ds -- \(bs-
  384. X.if (\n(.H=4u)&(1m=24u) .ds -- \(bs\h'-12u'\(bs\h'-12u'-\" diablo 10 pitch
  385. X.if (\n(.H=4u)&(1m=20u) .ds -- \(bs\h'-12u'\(bs\h'-8u'-\" diablo 12 pitch
  386. X.ds L" ""
  387. X.ds R" ""
  388. X.ds L' '
  389. X.ds R' '
  390. X'br\}
  391. X.el\{\
  392. X.ds -- \(em\|
  393. X.tr \*(Tr
  394. X.ds L" ``
  395. X.ds R" ''
  396. X.ds L' `
  397. X.ds R' '
  398. X'br\}
  399. X.TH RNMAIL 1 LOCAL
  400. X.SH NAME
  401. Rnmail - a program for replying via mail
  402. X.SH SYNOPSIS
  403. X.B Rnmail destination_list
  404. X.br
  405. X  or
  406. X.br
  407. X.B Rnmail -h headerfile [oldarticle]
  408. X.br
  409. X  or
  410. X.br
  411. X.B Rnmail
  412. X.SH DESCRIPTION
  413. Rnmail is a friendly interface for mailing replies to news articles.
  414. It will ask several questions, then allow you to enter your letter,
  415. and then mail it off.
  416. If you type h and a carriage return at any point,
  417. X.I Rnmail
  418. will tell you what it wants to know.
  419. X.PP
  420. The -h form is used when invoked from
  421. X.IR rn .
  422. If your editor can edit multiple files, and you want the article to which
  423. you are replying to show up as an alternate file, define the environment
  424. variable MAILPOSTER as \*(L"Rnmail -h %h %A\*(R".
  425. You can also modify the the MAILHEADER environment variable to change the
  426. header file that
  427. X.I rn
  428. passes to Rnmail.
  429. X.SH ENVIRONMENT
  430. X.IP DOTDIR 8
  431. If defined, specifies a place other than your home directory where 'dot' files
  432. may be stored.
  433. This is primarily for accounts which are shared by more than one person.
  434. X.Sp
  435. Default: $HOME
  436. X.IP EDITOR 8
  437. The editor you want to use, if VISUAL is undefined.
  438. X.Sp
  439. Default: whatever your news administrator installed, usually vi.
  440. X.IP HOME 8
  441. Your home directory.
  442. X.Sp
  443. Default: $LOGDIR
  444. X.IP LOGDIR 8
  445. Your home directory if HOME is undefined.
  446. X.IP LOGNAME 8
  447. Your login name, if USER is undefined.
  448. X.Sp
  449. Default: value of \*(L"whoami\*(R".
  450. X.IP MAILRECORD 8
  451. If defined, contains the name of a file to which the finished message will
  452. be appended.
  453. X.Sp
  454. Default: message not saved
  455. X.IP NEWSORG 8
  456. XEither the name of your organization, or the name of a file containing the
  457. name of your organization. (For use at organizations where the ORGANIZATION
  458. environmental variable is in use for other purposes). If both NEWSORG and 
  459. ORGANIZATION are set, NEWSORG will override ORGANIZATION.
  460. X.Sp
  461. Default: whatever your news administrator chose.
  462. X.IP ORGANIZATION 8
  463. XEither the name of your organization, or the name of a file containing the
  464. name of your organization.
  465. X.Sp
  466. Default: whatever your news administrator chose.
  467. X.IP REPLYTO 8
  468. The contents of a \*(L"Reply-To:\*(R" header line to insert into your message.
  469. X.Sp
  470. Default: header line not inserted.
  471. X.IP USER 8
  472. Your login name.
  473. X.Sp
  474. Default: $LOGNAME
  475. X.IP VISUAL 8
  476. The editor you want to use.
  477. X.Sp
  478. Default: $EDITOR
  479. X.SH FILES
  480. X$DOTDIR/.letter
  481. X.br
  482. X~/dead.letter
  483. X.SH SEE ALSO
  484. rn(1), Pnews(1), mail(1)
  485. X.SH DIAGNOSTICS
  486. X.SH BUGS
  487. Uses /bin/mail in the absence of sendmail.
  488. END_OF_FILE
  489. if test 3823 -ne `wc -c <'Rnmail.1'`; then
  490.     echo shar: \"'Rnmail.1'\" unpacked with wrong size!
  491. fi
  492. # end of 'Rnmail.1'
  493. fi
  494. if test -f 'artio.c' -a "${1}" != "-c" ; then 
  495.   echo shar: Will not clobber existing file \"'artio.c'\"
  496. else
  497. echo shar: Extracting \"'artio.c'\" \(5092 characters\)
  498. sed "s/^X//" >'artio.c' <<'END_OF_FILE'
  499. X/* $Id: artio.c,v 4.4 1991/09/09 20:18:23 sob Exp sob $
  500. X *
  501. X * $Log: artio.c,v $
  502. X * Revision 4.4  1991/09/09  20:18:23  sob
  503. X * release 4.4
  504. X *
  505. X *
  506. X * 
  507. X */
  508. X/* This software is Copyright 1991 by Stan Barber. 
  509. X *
  510. X * Permission is hereby granted to copy, reproduce, redistribute or otherwise
  511. X * use this software as long as: there is no monetary profit gained
  512. X * specifically from the use or reproduction of this software, it is not
  513. X * sold, rented, traded or otherwise marketed, and this copyright notice is
  514. X * included prominently in any copy made. 
  515. X *
  516. X * The author make no claims as to the fitness or correctness of this software
  517. X * for any use whatsoever, and it is provided as is. Any use of this software
  518. X * is at the user's own risk. 
  519. X */
  520. X
  521. X#include "EXTERN.h"
  522. X#include "common.h"
  523. X#ifdef SERVER
  524. X#include "server.h"
  525. X#endif
  526. X#include "INTERN.h"
  527. X#include "artio.h"
  528. X
  529. void
  530. artio_init()
  531. X{
  532. X    ;
  533. X}
  534. X
  535. X/* open an article, unless it's already open */
  536. X
  537. XFILE *
  538. artopen(artnum)
  539. ART_NUM artnum;
  540. X{
  541. X#ifdef SERVER
  542. X    return nntpopen(artnum,GET_ARTICLE);
  543. X#else
  544. X    char artname[MAXFILENAME];        /* filename of current article */
  545. X
  546. X    if (artnum < 1)
  547. X    return Nullfp;
  548. X    if (openart == artnum) {        /* this article is already open? */
  549. X    fseek(artfp,0L,0);        /* just get to the beginning */
  550. X    return artfp;            /* and say we succeeded */
  551. X    }
  552. X    if (artfp != Nullfp) {        /* it was somebody else? */
  553. X    fclose(artfp);            /* put them out of their misery */
  554. X    openart = 0;            /* and remember them no more */
  555. X    }
  556. X    sprintf(artname,"%ld",(long)artnum);
  557. X                    /* produce the name of the article */
  558. X    if (artfp = fopen(artname,"r"))    /* if we can open it */
  559. X    openart = artnum;        /* remember what we did here */
  560. X#ifdef LINKART
  561. X    {
  562. X    char tmpbuf[256];
  563. X    char *s;
  564. X
  565. X    if (fstat(fileno(artfp),&filestat))
  566. X        return artfp;
  567. X    if (filestat.st_size < (sizeof tmpbuf)) {
  568. X        fgets(tmpbuf,(sizeof tmpbuf),artfp);
  569. X        if (*tmpbuf == '/') {    /* is a "link" to another article */
  570. X        fclose(artfp);
  571. X        if (s=index(tmpbuf,'\n'))
  572. X            *s = '\0';
  573. X        if (!(artfp = fopen(tmpbuf,"r")))
  574. X            openart = 0;
  575. X        else {
  576. X            if (*linkartname)
  577. X            free(linkartname);
  578. X            linkartname = savestr(tmpbuf);
  579. X        }
  580. X        }
  581. X        else
  582. X        fseek(artfp,0L,0);        /* get back to the beginning */
  583. X    }
  584. X    }
  585. X#endif
  586. X    return artfp;            /* and return either fp or NULL */
  587. X#endif /* SERVER */
  588. X}
  589. X
  590. X#ifdef SERVER
  591. static long our_pid=0;
  592. X
  593. XFILE *
  594. nntpopen(artnum,function)
  595. ART_NUM artnum;
  596. ART_PART function;
  597. X{
  598. X    char artname[MAXFILENAME];        /* filename of current article */
  599. X    char intrpwork[MAXFILENAME];    /* filename of current article */
  600. X    if (our_pid == 0)
  601. X    our_pid = getpid();
  602. X    if (artnum < 1)
  603. X    return Nullfp;
  604. X    if ((openart == artnum) && (openpart >= function))
  605. X    {                    /* this article is already open? */
  606. X    fseek(artfp,0L,0);        /* just get to the beginning */
  607. X    return artfp;            /* and say we succeeded */
  608. X    }
  609. X    if (artfp != Nullfp) {        /* it was somebody else? */
  610. X    fclose(artfp);            /* put them out of their misery */
  611. X    nntpclose();
  612. X    openart = 0;            /* and remember them no more */
  613. X    }
  614. X    interp(intrpwork,MAXFILENAME-1,"%P");
  615. X    sprintf(artname,"%s/rrn%ld.%ld", intrpwork,(long) artnum, our_pid);
  616. X    artfp = fopen(artname, "w+");    /* create the temporary article */
  617. X    if (artfp == Nullfp) {
  618. X    UNLINK(artname);
  619. X    return Nullfp;
  620. X    }
  621. X    switch (function){
  622. X        case GET_STATUS:
  623. X        function = GET_HEADER;    /* fall through */
  624. X        case GET_HEADER:
  625. X        sprintf(ser_line, "HEAD %ld", (long)artnum);
  626. X        break;
  627. X        case GET_ARTICLE:
  628. X        sprintf(ser_line, "ARTICLE %ld", (long)artnum);
  629. X        break;
  630. X    }        
  631. X#ifdef DEBUGGING
  632. X    if (debug & DEB_NNTP)
  633. X    printf(">%s\n", ser_line) FLUSH;
  634. X#endif
  635. X    put_server(ser_line);        /* ask the server for the article */
  636. X    if (nntp_get(ser_line, sizeof(ser_line)) < 0) {
  637. X    fprintf(stderr, "\nrrn: Unexpected close of server socket.\n");
  638. X    finalize(1);
  639. X    }
  640. X#ifdef DEBUGGING
  641. X    if (debug & DEB_NNTP)
  642. X    printf("<%s\n", ser_line) FLUSH;
  643. X#endif
  644. X    if (*ser_line == CHAR_FATAL) {    /* Fatal error */
  645. X        fprintf(stderr,"\nrrn: %s\n",ser_line);
  646. X        finalize(1);
  647. X    }
  648. X    if (*ser_line != CHAR_OK) {        /* and get it's reaction */
  649. X    fclose(artfp);
  650. X    artfp = Nullfp;
  651. X    UNLINK(artname);
  652. X     errno = ENOENT;        /* Simulate file-not-found */
  653. X        return Nullfp;
  654. X    }
  655. X
  656. X    for (;;) {
  657. X        if (nntp_get(ser_line, sizeof(ser_line)) < 0) {
  658. X        fprintf(stderr, "\nrrn: Unexpected close of server socket.\n");
  659. X        finalize(1);
  660. X    }
  661. X    if (ser_line[0] == '.' && ser_line[1] == '\0')
  662. X        break;
  663. X    fputs((ser_line[0] == '.' ? ser_line + 1 : ser_line), artfp);
  664. X    putc('\n', artfp);
  665. X    }
  666. X    openpart = function;
  667. X    if (function == GET_HEADER)
  668. X     putc('\n', artfp); /* req'd blank line after header */
  669. X    fseek(artfp, 0L, 0);        /* Then get back to the start */
  670. X    openart = artnum;
  671. X    return artfp;            /* and return either fp or NULL */
  672. X}
  673. X
  674. void
  675. nntpclose()
  676. X{
  677. X    char artname[MAXFILENAME];        /* filename of current article */
  678. X    char intrpwork[MAXFILENAME];    /* filename of current article */
  679. X    if (our_pid == 0)
  680. X    our_pid = getpid();
  681. X    interp(intrpwork,MAXFILENAME-1,"%P");
  682. X    sprintf(artname, "%s/rrn%ld.%ld", intrpwork,(long) openart, our_pid);
  683. X    UNLINK(artname);
  684. X}
  685. X#endif
  686. END_OF_FILE
  687. if test 5092 -ne `wc -c <'artio.c'`; then
  688.     echo shar: \"'artio.c'\" unpacked with wrong size!
  689. fi
  690. # end of 'artio.c'
  691. fi
  692. if test -f 'backpage.c' -a "${1}" != "-c" ; then 
  693.   echo shar: Will not clobber existing file \"'backpage.c'\"
  694. else
  695. echo shar: Extracting \"'backpage.c'\" \(2658 characters\)
  696. sed "s/^X//" >'backpage.c' <<'END_OF_FILE'
  697. X/* $Id: backpage.c,v 4.4 1991/09/09 20:18:23 sob Exp sob $
  698. X *
  699. X * $Log: backpage.c,v $
  700. X * Revision 4.4  1991/09/09  20:18:23  sob
  701. X * release 4.4
  702. X *
  703. X *
  704. X * 
  705. X */
  706. X/* This software is Copyright 1991 by Stan Barber. 
  707. X *
  708. X * Permission is hereby granted to copy, reproduce, redistribute or otherwise
  709. X * use this software as long as: there is no monetary profit gained
  710. X * specifically from the use or reproduction of this software, it is not
  711. X * sold, rented, traded or otherwise marketed, and this copyright notice is
  712. X * included prominently in any copy made. 
  713. X *
  714. X * The author make no claims as to the fitness or correctness of this software
  715. X * for any use whatsoever, and it is provided as is. Any use of this software
  716. X * is at the user's own risk. 
  717. X */
  718. X
  719. X#include "EXTERN.h"
  720. X#include "common.h"
  721. X#include "intrp.h"
  722. X#include "final.h"
  723. X#include "INTERN.h"
  724. X#include "backpage.h"
  725. X
  726. ART_LINE maxindx = -1;
  727. long lseek();
  728. X
  729. void
  730. backpage_init()
  731. X{
  732. X    char *varyname;
  733. X    
  734. X    varyname = filexp(VARYNAME);
  735. X    close(creat(varyname,0600));
  736. X    varyfd = open(varyname,2);
  737. X    UNLINK(varyname);
  738. X    if (varyfd < 0) {
  739. X    printf(cantopen,varyname) FLUSH;
  740. X    sig_catcher(0);
  741. X    }
  742. X    
  743. X}
  744. X
  745. X/* virtual array read */
  746. X
  747. ART_POS
  748. vrdary(indx)
  749. ART_LINE indx;
  750. X{
  751. X    int subindx;
  752. X    long offset;
  753. X
  754. X#ifdef DEBUGGING
  755. X    if (indx > maxindx) {
  756. X    printf("vrdary(%ld) > %ld\n",(long)indx, (long)maxindx) FLUSH;
  757. X    return 0;
  758. X    }
  759. X#endif
  760. X    if (indx < 0)
  761. X    return 0;
  762. X    subindx = indx % VARYSIZE;
  763. X    offset = (indx - subindx) * sizeof(varybuf[0]);
  764. X    if (offset != oldoffset) {
  765. X    if (oldoffset >= 0) {
  766. X#ifndef lint
  767. X        (void)lseek(varyfd,oldoffset,0);
  768. X        write(varyfd, (char *)varybuf,sizeof(varybuf));
  769. X#endif /* lint */
  770. X    }
  771. X#ifndef lint
  772. X    (void)lseek(varyfd,offset,0);
  773. X    read(varyfd,(char *)varybuf,sizeof(varybuf));
  774. X#endif /* lint */
  775. X    oldoffset = offset;
  776. X    }
  777. X    return varybuf[subindx];
  778. X}
  779. X
  780. X/* write to virtual array */
  781. X
  782. void
  783. vwtary(indx,newvalue)
  784. ART_LINE indx;
  785. ART_POS newvalue;
  786. X{
  787. X    int subindx;
  788. X    long offset;
  789. X
  790. X#ifdef DEBUGGING
  791. X    if (indx < 0)
  792. X    printf("vwtary(%ld)\n",(long)indx) FLUSH;
  793. X    if (!indx)
  794. X    maxindx = 0;
  795. X    if (indx > maxindx) {
  796. X    if (indx != maxindx + 1)
  797. X        printf("indx skipped %d-%d\n",maxindx+1,indx-1) FLUSH;
  798. X    maxindx = indx;
  799. X    }
  800. X#endif
  801. X    subindx = indx % VARYSIZE;
  802. X    offset = (indx - subindx) * sizeof(varybuf[0]);
  803. X    if (offset != oldoffset) {
  804. X    if (oldoffset >= 0) {
  805. X#ifndef lint
  806. X        (void)lseek(varyfd,oldoffset,0);
  807. X        write(varyfd,(char *)varybuf,sizeof(varybuf));
  808. X#endif /* lint */
  809. X    }
  810. X#ifndef lint
  811. X    (void)lseek(varyfd,offset,0);
  812. X    read(varyfd,(char *)varybuf,sizeof(varybuf));
  813. X#endif /* lint */
  814. X    oldoffset = offset;
  815. X    }
  816. X    varybuf[subindx] = newvalue;
  817. X}
  818. X
  819. END_OF_FILE
  820. if test 2658 -ne `wc -c <'backpage.c'`; then
  821.     echo shar: \"'backpage.c'\" unpacked with wrong size!
  822. fi
  823. # end of 'backpage.c'
  824. fi
  825. if test -f 'bits.h' -a "${1}" != "-c" ; then 
  826.   echo shar: Will not clobber existing file \"'bits.h'\"
  827. else
  828. echo shar: Extracting \"'bits.h'\" \(2599 characters\)
  829. sed "s/^X//" >'bits.h' <<'END_OF_FILE'
  830. X/* $Id: bits.h,v 4.4 1991/09/09 20:18:23 sob Exp sob $
  831. X *
  832. X * $Log: bits.h,v $
  833. X * Revision 4.4  1991/09/09  20:18:23  sob
  834. X * release 4.4
  835. X *
  836. X *
  837. X * 
  838. X */
  839. X/* This software is Copyright 1991 by Stan Barber. 
  840. X *
  841. X * Permission is hereby granted to copy, reproduce, redistribute or otherwise
  842. X * use this software as long as: there is no monetary profit gained
  843. X * specifically from the use or reproduction of this software, it is not
  844. X * sold, rented, traded or otherwise marketed, and this copyright notice is
  845. X * included prominently in any copy made. 
  846. X *
  847. X * The author make no claims as to the fitness or correctness of this software
  848. X * for any use whatsoever, and it is provided as is. Any use of this software
  849. X * is at the user's own risk. 
  850. X */
  851. X
  852. XEXT char *ctlarea INIT(Nullch);    /* one bit for each article in current newsgroup */
  853. X            /* with the following interpretation: */
  854. X            /*    0 => unread  */
  855. X            /*    1 => read    */
  856. X
  857. X/* if subscripting is faster than shifting on your machine, define this */
  858. X#undef USESUBSCRIPT
  859. X#ifdef USESUBSCRIPT
  860. XEXT char powerof2[] INIT({1,2,4,8,16,32,64,128});
  861. X#define pow2(x) powerof2[x]
  862. X#else
  863. X#define pow2(x) (1 << (x))
  864. X#endif
  865. X
  866. X#ifdef lint
  867. XEXT bool nonesuch INIT(FALSE);
  868. X#define ctl_set(a)
  869. X#define ctl_clear(a)
  870. X#define ctl_read(a) nonesuch
  871. X#define was_read(a) nonesuch
  872. X#else
  873. X#define ctl_set(a) (ctlarea[(OFFSET(a)) / BITSPERBYTE] |= pow2((OFFSET(a)) % BITSPERBYTE))
  874. X#define ctl_clear(a) (ctlarea[(OFFSET(a)) / BITSPERBYTE] &= ~pow2((OFFSET(a)) % BITSPERBYTE))
  875. X#define ctl_read(a) ((ctlarea[(OFFSET(a)) / BITSPERBYTE] & pow2((OFFSET(a)) % BITSPERBYTE)) != 0)
  876. X
  877. X#define was_read(a) ((a)<firstbit || ctl_read(a))
  878. X#endif /* lint */
  879. X
  880. XEXT ART_NUM absfirst INIT(0);    /* 1st real article in current newsgroup */
  881. XEXT ART_NUM firstart INIT(0);    /* minimum unread article number in newsgroup */
  882. XEXT ART_NUM firstbit INIT(0);    /* minimum valid bit, usually == firstart */
  883. XEXT ART_NUM lastart INIT(0);    /* maximum article number in newsgroup */
  884. X
  885. X#ifdef DELAYMARK
  886. XEXT FILE *dmfp INIT(Nullfp);
  887. XEXT char *dmname INIT(Nullch);
  888. XEXT int dmcount INIT(0);
  889. X#endif
  890. X
  891. void    bits_init ANSI((void));
  892. void    checkpoint_rc ANSI((void));
  893. void    restore_ng ANSI((void));
  894. void    onemore ANSI((ART_NUM));
  895. void    oneless ANSI((ART_NUM));
  896. void    unmark_as_read ANSI((void));
  897. X#ifdef USETHREADS
  898. void    set_read ANSI((ART_NUM,int,bool_int));
  899. void    set_unread ANSI((ART_NUM,int));
  900. X#endif
  901. void    delay_unmark ANSI((ART_NUM));
  902. void    mark_as_read ANSI((void));
  903. void    check_first ANSI((ART_NUM));
  904. X#ifdef DELAYMARK
  905. X    void    yankback ANSI((void));
  906. X#endif
  907. int    chase_xrefs ANSI((ART_NUM,int));
  908. int    initctl ANSI((void));
  909. void    grow_ctl ANSI((ART_NUM));
  910. END_OF_FILE
  911. if test 2599 -ne `wc -c <'bits.h'`; then
  912.     echo shar: \"'bits.h'\" unpacked with wrong size!
  913. fi
  914. # end of 'bits.h'
  915. fi
  916. if test -f 'cheat.c' -a "${1}" != "-c" ; then 
  917.   echo shar: Will not clobber existing file \"'cheat.c'\"
  918. else
  919. echo shar: Extracting \"'cheat.c'\" \(3484 characters\)
  920. sed "s/^X//" >'cheat.c' <<'END_OF_FILE'
  921. X/* $Id: cheat.c,v 4.4.2.1 1991/12/01 18:05:42 sob PATCH_2 sob $
  922. X *
  923. X * $Log: cheat.c,v $
  924. X * Revision 4.4.2.1  1991/12/01  18:05:42  sob
  925. X * Patchlevel 2 changes
  926. X *
  927. X * Revision 4.4  1991/09/09  20:18:23  sob
  928. X * release 4.4
  929. X *
  930. X *
  931. X * 
  932. X */
  933. X/* This software is Copyright 1991 by Stan Barber. 
  934. X *
  935. X * Permission is hereby granted to copy, reproduce, redistribute or otherwise
  936. X * use this software as long as: there is no monetary profit gained
  937. X * specifically from the use or reproduction of this software, it is not
  938. X * sold, rented, traded or otherwise marketed, and this copyright notice is
  939. X * included prominently in any copy made. 
  940. X *
  941. X * The author make no claims as to the fitness or correctness of this software
  942. X * for any use whatsoever, and it is provided as is. Any use of this software
  943. X * is at the user's own risk. 
  944. X */
  945. X
  946. X#include "EXTERN.h"
  947. X#include "common.h"
  948. X#include "intrp.h"
  949. X#include "search.h"
  950. X#include "ng.h"
  951. X#include "bits.h"
  952. X#include "artio.h"
  953. X#include "term.h"
  954. X#include "artsrch.h"
  955. X#include "head.h"
  956. X#include "INTERN.h"
  957. X#include "cheat.h"
  958. X
  959. X/* see what we can do while they are reading */
  960. X
  961. X#ifdef PENDING
  962. X#   ifdef ARTSEARCH
  963. X    COMPEX srchcompex;        /* compiled regex for searchahead */
  964. X#   endif
  965. X#endif
  966. X
  967. void
  968. cheat_init()
  969. X{
  970. X    ;
  971. X}
  972. X
  973. X#ifdef PENDING
  974. void
  975. look_ahead()
  976. X{
  977. X#ifdef ARTSEARCH
  978. X    register char *h, *s;
  979. X
  980. X#ifdef DEBUGGING
  981. X    if (debug && srchahead) {
  982. X    printf("(%ld)",(long)srchahead);
  983. X    fflush(stdout);
  984. X    }
  985. X#endif
  986. X    if (srchahead && srchahead < art) {    /* in ^N mode? */
  987. X    char *pattern;
  988. X
  989. X    pattern = buf+1;
  990. X    strcpy(pattern,": *");
  991. X    h = pattern + strlen(pattern);
  992. X    interp(h,(sizeof buf) - (h-buf),"%\\s");
  993. X    {            /* compensate for notesfiles */
  994. X        register int i;
  995. X        for (i = 24; *h && i--; h++)
  996. X        if (*h == '\\')
  997. X            h++;
  998. X        *h = '\0';
  999. X    }
  1000. X#ifdef DEBUGGING
  1001. X    if (debug & DEB_SEARCH_AHEAD) {
  1002. X        fputs("(hit CR)",stdout);
  1003. X        fflush(stdout);
  1004. X        gets(buf+128);
  1005. X        printf("\npattern = %s\n",pattern);
  1006. X    }
  1007. X#endif
  1008. X    if ((s = compile(&srchcompex,pattern,TRUE,TRUE)) != Nullch) {
  1009. X                    /* compile regular expression */
  1010. X        printf("\n%s\n",s);
  1011. X        srchahead = 0;
  1012. X    }
  1013. X    if (srchahead) {
  1014. X        srchahead = art;
  1015. X        for (;;) {
  1016. X        srchahead++;    /* go forward one article */
  1017. X        if (srchahead > lastart) { /* out of articles? */
  1018. X#ifdef DEBUGGING
  1019. X            if (debug)
  1020. X            fputs("(not found)",stdout);
  1021. X#endif
  1022. X            break;
  1023. X        }
  1024. X        if (!was_read(srchahead) &&
  1025. X            wanted(&srchcompex,srchahead,0)) {
  1026. X                    /* does the shoe fit? */
  1027. X#ifdef DEBUGGING
  1028. X            if (debug)
  1029. X            printf("(%ld)",(long)srchahead);
  1030. X#endif
  1031. X#ifdef SERVER
  1032. X            nntpopen(srchahead,GET_HEADER);
  1033. X#else
  1034. X            artopen(srchahead);
  1035. X#endif
  1036. X            break;
  1037. X        }
  1038. X        if (input_pending())
  1039. X            break;
  1040. X        }
  1041. X        fflush(stdout);
  1042. X    }
  1043. X    }
  1044. X    else
  1045. X#endif
  1046. X    {
  1047. X    if (art+1 <= lastart)/* how about a pre-fetch? */
  1048. X#ifdef SERVER
  1049. X        nntpopen(art+1,GET_HEADER);    /* look for the next article */
  1050. X#else
  1051. X        artopen(art+1);    /* look for the next article */
  1052. X#endif
  1053. X    }
  1054. X}
  1055. X#endif
  1056. X
  1057. X/* see what else we can do while they are reading */
  1058. X
  1059. void
  1060. collect_subjects()
  1061. X{
  1062. X#ifdef PENDING
  1063. X# ifdef CACHESUBJ
  1064. X    ART_NUM oldart = openart;
  1065. X    ART_POS oldartpos;
  1066. X
  1067. X    if (!in_ng || !srchahead)
  1068. X    return;
  1069. X    if (oldart)            /* remember where we were in art */
  1070. X    oldartpos = ftell(artfp);
  1071. X    if (srchahead >= subj_to_get)
  1072. X    subj_to_get = srchahead+1;
  1073. X    while (!input_pending() && subj_to_get <= lastart)
  1074. X    fetchsubj(subj_to_get++,FALSE,FALSE);
  1075. X    if (oldart) {
  1076. X    artopen(oldart);
  1077. X    fseek(artfp,oldartpos,0);    /* do not screw the pager */
  1078. X    }
  1079. X# endif
  1080. X#endif
  1081. X}
  1082. X
  1083. END_OF_FILE
  1084. if test 3484 -ne `wc -c <'cheat.c'`; then
  1085.     echo shar: \"'cheat.c'\" unpacked with wrong size!
  1086. fi
  1087. # end of 'cheat.c'
  1088. fi
  1089. if test -f 'getactive.c' -a "${1}" != "-c" ; then 
  1090.   echo shar: Will not clobber existing file \"'getactive.c'\"
  1091. else
  1092. echo shar: Extracting \"'getactive.c'\" \(2631 characters\)
  1093. sed "s/^X//" >'getactive.c' <<'END_OF_FILE'
  1094. X/* $Id: getactive.c,v 4.4 1991/09/09 20:18:23 sob Exp sob $
  1095. X *
  1096. X * $Log: getactive.c,v $
  1097. X * Revision 4.4  1991/09/09  20:18:23  sob
  1098. X * release 4.4
  1099. X *
  1100. X *
  1101. X * 
  1102. X *
  1103. X */
  1104. X/* This software is Copyright 1991 by Stan Barber. 
  1105. X *
  1106. X * Permission is hereby granted to copy, reproduce, redistribute or otherwise
  1107. X * use this software as long as: there is no monetary profit gained
  1108. X * specifically from the use or reproduction of this software, it is not
  1109. X * sold, rented, traded or otherwise marketed, and this copyright notice is
  1110. X * included prominently in any copy made. 
  1111. X *
  1112. X * The author make no claims as to the fitness or correctness of this software
  1113. X * for any use whatsoever, and it is provided as is. Any use of this software
  1114. X * is at the user's own risk. 
  1115. X */
  1116. X#include <stdio.h>
  1117. X#include "config.h"
  1118. X#include <signal.h>
  1119. X/* what to do with ansi prototypes -- '()' == ignore, 'x' == use */
  1120. X#ifndef ANSI
  1121. X#   define ANSI(x) ()
  1122. X#endif
  1123. X#include "INTERN.h"
  1124. X#ifdef SERVER
  1125. X#include "server.h"
  1126. X#endif
  1127. X
  1128. main(argc, argv)
  1129. X    int        argc;
  1130. X    char         *argv[];
  1131. X{
  1132. X    char        ser_line[NNTP_STRLEN];
  1133. X    char        command[32];
  1134. X    int        response;
  1135. X    char         *action;
  1136. X    register char    *server;
  1137. X    register FILE    *actfp;
  1138. X
  1139. X    if (argc < 2 || argc > 3) {
  1140. X        fprintf(stderr, "Usage: getactive [active|distributions|newsgroups] filename\n");
  1141. X        exit(1);
  1142. X    }
  1143. X    if (argc == 2) action = "ACTIVE";
  1144. X    else{
  1145. X         action = argv[1];
  1146. X         argc--;
  1147. X         argv++;
  1148. X    }
  1149. X    if ((server = get_server_name(1)) == NULL)
  1150. X        exit(1);
  1151. X    response = server_init(server);
  1152. X    if (response < 0) {
  1153. X        fprintf(stderr,
  1154. X            "getactive: Can't get %s file from server %s.\n",
  1155. X                action, server);
  1156. X        exit(1);
  1157. X    }
  1158. X
  1159. X    if (handle_server_response(response, server) < 0)
  1160. X        exit(1);
  1161. X
  1162. X    sprintf(command,"LIST %s",action);
  1163. X    put_server(command); 
  1164. X#ifdef HAVESIGHOLD
  1165. X     sighold(SIGINT);
  1166. X#endif
  1167. X    (void) get_server(ser_line, sizeof(ser_line));
  1168. X    if (*ser_line != CHAR_OK) {        /* and then see if that's ok */
  1169. X        fprintf(stderr,
  1170. X            "getactive: Can't get %s file from server.\n",action);
  1171. X        fprintf(stderr, "Server said: %s\n", ser_line);
  1172. X        exit(1);
  1173. X    }
  1174. X
  1175. X    actfp = fopen(argv[1], "w");        /* and get ready */
  1176. X    if (actfp == NULL) {
  1177. X        close_server();
  1178. X        perror(argv[1]);
  1179. X        exit(1);
  1180. X    }
  1181. X
  1182. X    while (get_server(ser_line, sizeof(ser_line)) >= 0) {  /* while */
  1183. X        if (ser_line[0] == '.')        /* there's another line */
  1184. X            break;            /* get it and write it to */
  1185. X        if (actfp != NULL) {        /* the temporary active file */
  1186. X            fputs(ser_line, actfp);
  1187. X            putc('\n', actfp);
  1188. X        }
  1189. X    }
  1190. X
  1191. X    if (ferror(actfp)) {
  1192. X         perror(argv[1]);
  1193. X         exit(1);
  1194. X    }
  1195. X
  1196. X    if (fclose(actfp) == EOF) {
  1197. X         perror(argv[1]);
  1198. X         exit(1);
  1199. X    }
  1200. X
  1201. X#ifdef HAVESIGHOLD
  1202. X
  1203. X    exit(0);
  1204. X    sigrelse(SIGINT);
  1205. X#endif
  1206. X    close_server();
  1207. X    exit(0);
  1208. X}
  1209. END_OF_FILE
  1210. if test 2631 -ne `wc -c <'getactive.c'`; then
  1211.     echo shar: \"'getactive.c'\" unpacked with wrong size!
  1212. fi
  1213. # end of 'getactive.c'
  1214. fi
  1215. if test -f 'head.h' -a "${1}" != "-c" ; then 
  1216.   echo shar: Will not clobber existing file \"'head.h'\"
  1217. else
  1218. echo shar: Extracting \"'head.h'\" \(5071 characters\)
  1219. sed "s/^X//" >'head.h' <<'END_OF_FILE'
  1220. X/* $Id: head.h,v 4.4 1991/09/09 20:18:23 sob Exp sob $
  1221. X *
  1222. X * $Log: head.h,v $
  1223. X * Revision 4.4  1991/09/09  20:18:23  sob
  1224. X * release 4.4
  1225. X *
  1226. X *
  1227. X * 
  1228. X */
  1229. X/* This software is Copyright 1991 by Stan Barber. 
  1230. X *
  1231. X * Permission is hereby granted to copy, reproduce, redistribute or otherwise
  1232. X * use this software as long as: there is no monetary profit gained
  1233. X * specifically from the use or reproduction of this software, it is not
  1234. X * sold, rented, traded or otherwise marketed, and this copyright notice is
  1235. X * included prominently in any copy made. 
  1236. X *
  1237. X * The author make no claims as to the fitness or correctness of this software
  1238. X * for any use whatsoever, and it is provided as is. Any use of this software
  1239. X * is at the user's own risk. 
  1240. X */
  1241. X
  1242. X#define HEAD_FIRST 1
  1243. X
  1244. X/* types of header lines (if only C really believed in enums)
  1245. X * (These must stay in alphabetic order at least in the first letter.
  1246. X * Within each letter it helps to arrange in increasing likelihood.)
  1247. X */
  1248. X
  1249. X#define PAST_HEADER    0    /* body */
  1250. X#define SOME_LINE    1    /* unrecognized */
  1251. X#define ARTID_LINE    2    /* article-i.d. */
  1252. X#define APPR_LINE    3    /* approved */
  1253. X#define ACAT_LINE    4    /* ACategory (ClariNet) */
  1254. X#define ANPA_LINE    5    /* ANPA (ClariNet) */
  1255. X#define CODES_LINE    6    /* Codes (ClariNet) */
  1256. X#define DIST_LINE    7    /* distribution */
  1257. X#define DATE_LINE    8    /* date */
  1258. X#define RECEIVED_LINE    9    /* date-received */
  1259. X#define EXPIR_LINE    10    /* expires */
  1260. X#define FOLLOW_LINE    11    /* followup-to */
  1261. X#define FROM_LINE    12    /* from */
  1262. X#define FORM_LINE    13    /* Format (ClariNet) */
  1263. X#define KEYW_LINE    14    /* keywords */
  1264. X#define LINES_LINE    15    /* lines */
  1265. X#define MESSID_LINE    16    /* message-id */
  1266. X#define NFFR_LINE    17    /* nf-from */
  1267. X#define NFID_LINE    18    /* nf-id */
  1268. X#define NGS_LINE    19    /* newsgroups */
  1269. X#define NOTE_LINE    20    /* Note (ClariNet) */
  1270. X#define ORG_LINE    21    /* organization */
  1271. X#define PATH_LINE    22    /* path */
  1272. X#define POSTED_LINE    23    /* posted */
  1273. X#define PVER_LINE    24    /* posting-version */
  1274. X#define PRI_LINE    25    /* Priority (ClariNet) */
  1275. X#define REPLY_LINE    26    /* reply-to */
  1276. X#define REFS_LINE    27    /* references */
  1277. X#define RVER_LINE    28    /* relay-version */
  1278. X#define SENDER_LINE    29    /* sender */
  1279. X#define SUMRY_LINE    30    /* summary */
  1280. X#define SUBJ_LINE    31    /* subject */
  1281. X#define SLUG_LINE    32    /* Slugword (ClariNet) */
  1282. X#define XREF_LINE    33    /* xref */
  1283. X#define XSUP_LINE    34    /* X-Supersedes (ClariNet) */
  1284. X#define HEAD_LAST    35    /* one more than the last one above */
  1285. X
  1286. struct headtype {
  1287. X    char *ht_name;        /* header line identifier */
  1288. X#ifdef pdp11
  1289. X    short ht_minpos;
  1290. X    short ht_maxpos;
  1291. X#else
  1292. X    ART_POS ht_minpos;        /* pointer to beginning of line in article */
  1293. X    ART_POS ht_maxpos;        /* pointer to end of line in article */
  1294. X#endif
  1295. X    char ht_length;        /* could make these into nybbles but */
  1296. X    char ht_flags;        /* it wouldn't save space normally */
  1297. X};                /* due to alignment considerations */
  1298. X
  1299. X#define HT_HIDE 1    /* -h on this line */
  1300. X#define HT_MAGIC 2    /* do any special processing on this line */
  1301. X
  1302. X/* This array must stay in the same order as the list above */
  1303. X
  1304. X#ifndef DOINIT
  1305. XEXT struct headtype htype[HEAD_LAST];
  1306. X#else
  1307. struct headtype htype[HEAD_LAST] = {
  1308. X /* name             minpos   maxpos  length   flag */
  1309. X    {"BODY",        0,    0,    4,    0        },
  1310. X    {"unrecognized",    0,    0,    12,    0        },
  1311. X    {"article-i.d.",    0,    0,    12,    HT_HIDE        },
  1312. X    {"approved",    0,    0,    8,    HT_HIDE        },
  1313. X    {"acategory",    0,    0,    9,    HT_HIDE        },
  1314. X    {"anpa",        0,    0,    4,    HT_HIDE        },
  1315. X    {"codes",        0,    0,    5,    HT_HIDE        },
  1316. X    {"distribution",    0,    0,    12,    0        },
  1317. X#ifdef USETHREADS
  1318. X    {"date",        0,    0,    4,    HT_MAGIC    },
  1319. X#else
  1320. X    {"date",        0,    0,    4,    0        },
  1321. X#endif
  1322. X    {"date-received",    0,    0,    13,    0        },
  1323. X    {"expires",        0,    0,    7,    HT_HIDE|HT_MAGIC},
  1324. X    {"followup-to",    0,    0,    11,    0        },
  1325. X    {"from",        0,    0,    4,    HT_MAGIC    },
  1326. X    {"format",        0,    0,    6,    HT_HIDE        },
  1327. X    {"keywords",    0,    0,    8,    0        },
  1328. X    {"lines",        0,    0,    5,    0        },
  1329. X    {"message-id",    0,    0,    10,    HT_HIDE        },
  1330. X    {"nf-from",        0,    0,    7,    HT_HIDE        },
  1331. X    {"nf-id",        0,    0,    5,    HT_HIDE        },
  1332. X    {"newsgroups",    0,    0,    10,    HT_MAGIC|HT_HIDE},
  1333. X    {"note",        0,    0,    4,    0,        },
  1334. X    {"organization",    0,    0,    12,    0        },
  1335. X    {"path",        0,    0,    4,    HT_HIDE        },
  1336. X    {"posted",        0,    0,    6,    HT_HIDE        },
  1337. X    {"posting-version",    0,    0,    15,    HT_HIDE        },
  1338. X    {"priority",    0,    0,    8,    HT_HIDE        },
  1339. X    {"reply-to",    0,    0,    8,    HT_HIDE        },
  1340. X    {"references",    0,    0,    10,    HT_HIDE        },
  1341. X    {"relay-version",    0,    0,    13,    HT_HIDE        },
  1342. X    {"sender",        0,    0,    6,    HT_HIDE        },
  1343. X    {"summary",        0,    0,    7,    0        },
  1344. X    {"subject",        0,    0,    7,    HT_MAGIC    },
  1345. X    {"slugword",    0,    0,    8,    HT_HIDE        },
  1346. X    {"xref",        0,    0,    4,    HT_HIDE        },
  1347. X    {"x-supersedes",    0,    0,    12,    HT_HIDE        }
  1348. X};
  1349. X#endif
  1350. X
  1351. X#ifdef ASYNC_PARSE
  1352. XEXT ART_NUM parsed_art INIT(0);
  1353. X#endif
  1354. X
  1355. XEXT char in_header INIT(0);        /* are we decoding the header? */
  1356. X
  1357. X#ifdef CACHESUBJ
  1358. X    EXT char **subj_list INIT(Null(char **));
  1359. X#endif
  1360. X
  1361. void    head_init ANSI((void));
  1362. int    set_line_type ANSI((char *,char *));
  1363. void    start_header ANSI((ART_NUM));
  1364. bool    parseline ANSI((char *,int,int));
  1365. X#ifdef ASYNC_PARSE
  1366. X    int        parse_maybe ANSI((ART_NUM));
  1367. X#endif
  1368. char    *fetchsubj ANSI((ART_NUM,bool_int,bool_int));
  1369. char    *fetchlines ANSI((ART_NUM,int));
  1370. X
  1371. X#ifdef DEBUGGING
  1372. void    dumpheader ANSI((char *));
  1373. X#endif
  1374. END_OF_FILE
  1375. if test 5071 -ne `wc -c <'head.h'`; then
  1376.     echo shar: \"'head.h'\" unpacked with wrong size!
  1377. fi
  1378. # end of 'head.h'
  1379. fi
  1380. if test -f 'last.c' -a "${1}" != "-c" ; then 
  1381.   echo shar: Will not clobber existing file \"'last.c'\"
  1382. else
  1383. echo shar: Extracting \"'last.c'\" \(2086 characters\)
  1384. sed "s/^X//" >'last.c' <<'END_OF_FILE'
  1385. X/* $Id: last.c,v 4.4 1991/09/09 20:23:31 sob Exp sob $
  1386. X *
  1387. X * $Log: last.c,v $
  1388. X * Revision 4.4  1991/09/09  20:23:31  sob
  1389. X * release 4.4
  1390. X *
  1391. X *
  1392. X * 
  1393. X */
  1394. X/* This software is Copyright 1991 by Stan Barber. 
  1395. X *
  1396. X * Permission is hereby granted to copy, reproduce, redistribute or otherwise
  1397. X * use this software as long as: there is no monetary profit gained
  1398. X * specifically from the use or reproduction of this software, it is not
  1399. X * sold, rented, traded or otherwise marketed, and this copyright notice is
  1400. X * included prominently in any copy made. 
  1401. X *
  1402. X * The author make no claims as to the fitness or correctness of this software
  1403. X * for any use whatsoever, and it is provided as is. Any use of this software
  1404. X * is at the user's own risk. 
  1405. X */
  1406. X
  1407. X#include "EXTERN.h"
  1408. X#include "common.h"
  1409. X#include "rn.h"
  1410. X#include "util.h"
  1411. X#include "intrp.h"
  1412. X#include "INTERN.h"
  1413. X#include "last.h"
  1414. X
  1415. char *lastname = Nullch;    /* path name of .rnlast file */
  1416. X
  1417. void
  1418. last_init(tcbuf)
  1419. char *tcbuf;
  1420. X{
  1421. X    lastname = savestr(filexp(LASTNAME));
  1422. X    if ((tmpfp = fopen(lastname,"r")) != Nullfp &&
  1423. X    fgets(tcbuf,1024,tmpfp) != Nullch) {
  1424. X    tcbuf[strlen(tcbuf)-1] = '\0';
  1425. X    lastngname = savestr(tcbuf);
  1426. X    fgets(tcbuf,1024,tmpfp);
  1427. X    lasttime = atol(tcbuf);
  1428. X    fgets(tcbuf,1024,tmpfp);
  1429. X    lastactsiz = atol(tcbuf);
  1430. X    if (fgets(tcbuf,1024,tmpfp) != Nullch)
  1431. X        lastnewtime = atol(tcbuf);
  1432. X    else
  1433. X        lastnewtime = (lasttime? lasttime : time(Null(time_t*))-24L*60*60);
  1434. X    if (fgets(tcbuf,1024,tmpfp) != Nullch)
  1435. X        lastnewsize = atol(tcbuf);
  1436. X    else
  1437. X        lastnewsize = 0;
  1438. X    fclose(tmpfp);
  1439. X    }
  1440. X    else {
  1441. X    lastngname = nullstr;
  1442. X    lasttime = 0;
  1443. X    lastactsiz = 0;
  1444. X    lastnewsize = 0;
  1445. X    /* Use yesterday as an initial value for finding new groups. */
  1446. X    lastnewtime = time(Null(time_t*)) - 24L*60*60;
  1447. X    }
  1448. X}
  1449. X
  1450. X/* put out certain values for next run of rn */
  1451. X
  1452. void
  1453. writelast()
  1454. X{
  1455. X    if ((tmpfp = fopen(lastname,"w")) != Nullfp) {
  1456. X    fprintf(tmpfp,"%s\n%ld\n%ld\n%ld\n%ld\n",
  1457. X        (ngname==Nullch?nullstr:ngname),(long)lasttime,(long)lastactsiz,
  1458. X        (long)lastnewtime,(long)lastnewsize);
  1459. X    fclose(tmpfp);
  1460. X    }
  1461. X    else
  1462. X    printf(cantcreate,lastname) FLUSH;
  1463. X}
  1464. END_OF_FILE
  1465. if test 2086 -ne `wc -c <'last.c'`; then
  1466.     echo shar: \"'last.c'\" unpacked with wrong size!
  1467. fi
  1468. # end of 'last.c'
  1469. fi
  1470. if test -f 'makedepend.SH' -a "${1}" != "-c" ; then 
  1471.   echo shar: Will not clobber existing file \"'makedepend.SH'\"
  1472. else
  1473. echo shar: Extracting \"'makedepend.SH'\" \(2576 characters\)
  1474. sed "s/^X//" >'makedepend.SH' <<'END_OF_FILE'
  1475. case $CONFIG in
  1476. X    '') . ./config.sh ;;
  1477. esac
  1478. echo "Extracting makedepend (with variable substitutions)"
  1479. X$spitshell >makedepend <<!GROK!THIS!
  1480. X$startsh
  1481. X# $Id: makedepend.SH,v 4.4 1991/09/09 20:23:31 sob Exp sob $
  1482. X#
  1483. X# $Log: makedepend.SH,v $
  1484. X# Revision 4.4  1991/09/09  20:23:31  sob
  1485. X# release 4.4
  1486. X#
  1487. X# 
  1488. X# This software is Copyright 1991 by Stan Barber. 
  1489. X#
  1490. X# Permission is hereby granted to copy, reproduce, redistribute or otherwise
  1491. X# use this software as long as: there is no monetary profit gained
  1492. X# specifically from the use or reproduction of this software, it is not
  1493. X# sold, rented, traded or otherwise marketed, and this copyright notice is
  1494. X# included prominently in any copy made. 
  1495. X#
  1496. X# The author make no claims as to the fitness or correctness of this software
  1497. X# for any use whatsoever, and it is provided as is. Any use of this software
  1498. X# is at the user's own risk. 
  1499. export PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh \$0; kill \$\$)
  1500. X
  1501. X$cat /dev/null >.deptmp
  1502. X$echo "(Note: this is going to take a while.)"
  1503. X$rm -f X*.c
  1504. for file in *.c; do
  1505. X    filebase=\`basename \$file .c\`
  1506. X    $echo "Finding dependencies for \$filebase.o."
  1507. X    $sed -n <\$file >X\$file \\
  1508. X    -e "/^\${filebase}_init(/q" \\
  1509. X    -e '/^#/{' \\
  1510. X    -e 's|/\*.*$||' \\
  1511. X    -e p \\
  1512. X    -e '}'
  1513. X    $cpp -I/usr/local/include X\$file | $sed  \\
  1514. X    -e '/^# *line/s/line//' \
  1515. X    -e '/^# *[0-9]/!d' \\
  1516. X    -e 's/^.*"\(.*\)".*\$/'\$filebase'.o: \1/' \\
  1517. X    -e 's|: \./|: |' \\
  1518. X    -e 's|: X|: |' | \\
  1519. X    $uniq | $sort | $uniq >> .deptmp
  1520. done
  1521. X
  1522. for file in *.SH; do
  1523. X    $echo \`basename \$file .SH\`: \$file config.sh \; /bin/sh \$file >> .deptmp
  1524. done
  1525. X
  1526. X$sed <Makefile >Makefile.new -e '1,/^# AUTOMATICALLY/!d'
  1527. X
  1528. if $test -s .deptmp; then
  1529. X    echo "Updating Makefile..."
  1530. X    echo "# If this runs make out of memory, delete /usr/include lines." >>Makefile.new
  1531. X    $sed -e 's/\\\$/\$\$/g' .deptmp >>Makefile.new
  1532. else
  1533. X    $echo "You don't seem to have a proper C preprocessor.  Using grep instead."
  1534. X    $egrep '^#include ' *.c *.h >.deptmp
  1535. X    echo "Updating Makefile..."
  1536. X    <.deptmp $sed -n 's|c:#include "\(.*\)".*\$\$|o: \1|p' >> Makefile.new
  1537. X    <.deptmp $sed -n 's|c:#include <\(.*\)>.*\$\$|o: /usr/include/\1|p' >> Makefile.new
  1538. X    <.deptmp $sed -n 's|h:#include "\(.*\)".*\$\$|h: \1|p' >> Makefile.new
  1539. X    <.deptmp $sed -n 's|h:#include <\(.*\)>.*\$\$|h: /usr/include/\1|p' >> Makefile.new
  1540. fi
  1541. X$mv Makefile Makefile.old
  1542. X$mv Makefile.new Makefile
  1543. X$echo "# WARNING: Put nothing here or make depend will gobble it up!" >> Makefile
  1544. rm .deptmp X*.c
  1545. X
  1546. X!GROK!THIS!
  1547. X$eunicefix makedepend
  1548. chmod 755 makedepend
  1549. END_OF_FILE
  1550. if test 2576 -ne `wc -c <'makedepend.SH'`; then
  1551.     echo shar: \"'makedepend.SH'\" unpacked with wrong size!
  1552. fi
  1553. # end of 'makedepend.SH'
  1554. fi
  1555. if test -f 'mt-misc.c' -a "${1}" != "-c" ; then 
  1556.   echo shar: Will not clobber existing file \"'mt-misc.c'\"
  1557. else
  1558. echo shar: Extracting \"'mt-misc.c'\" \(4834 characters\)
  1559. sed "s/^X//" >'mt-misc.c' <<'END_OF_FILE'
  1560. X/* $Id: mt-misc.c,v 4.4.3.1 1991/11/22 04:12:15 davison Trn $
  1561. X**
  1562. X** $Log: mt-misc.c,v $
  1563. X** Revision 4.4.3.1  1991/11/22  04:12:15  davison
  1564. X** Trn Release 2.0
  1565. X** 
  1566. X*/
  1567. X
  1568. X#include "EXTERN.h"
  1569. X#include "common.h"
  1570. X#include "threads.h"
  1571. X#include "mthreads.h"
  1572. X
  1573. char *lib, *rnlib, *mtlib, *spool, *threaddir, *homedir;
  1574. int locked = 0, cron_locking = 0;
  1575. X
  1576. void
  1577. mt_init()
  1578. X{
  1579. X    /* Set up a nice friendly umask. */
  1580. X    umask(002);
  1581. X
  1582. X    /* Init the directory strings, possibly translating them into real paths */
  1583. X    homedir = getenv("HOME");
  1584. X    if (homedir == Nullch) {
  1585. X    homedir = getenv("LOGDIR");
  1586. X    }
  1587. X    spool = savestr(file_exp(SPOOL));
  1588. X    lib = savestr(file_exp(LIB));
  1589. X    rnlib = savestr(file_exp(RNLIB));
  1590. X    mtlib = savestr(file_exp(MTLIB));
  1591. X    threaddir = savestr(file_exp(THREAD_DIR));
  1592. X}
  1593. X
  1594. X/* Make sure we're not already running by creating a lock file. */
  1595. long
  1596. mt_lock(which_lock, sig)
  1597. int which_lock;
  1598. int sig;
  1599. X{
  1600. X    char buff[LBUFLEN], *filename;
  1601. X    FILE *fp;
  1602. X
  1603. X    sprintf(buff, "%s.%ld", file_exp(MTPRELOCK), (long)getpid());
  1604. X    if ((fp = fopen(buff, "w")) == Nullfp) {
  1605. X    log_entry("Unable to create lock temporary `%s'.\n", buff);
  1606. X    wrap_it_up(1);
  1607. X    }
  1608. X    fprintf(fp, "%s%ld\n", which_lock == DAEMON_LOCK ? "pid " : nullstr,
  1609. X    (long)getpid());
  1610. X    fclose(fp);
  1611. X
  1612. X    /* Try to link to lock file. */
  1613. X    if (which_lock == DAEMON_LOCK) {
  1614. X    filename = file_exp(MTDLOCK);
  1615. X    } else {
  1616. X    filename = file_exp(MTLOCK);
  1617. X    }
  1618. X  dolink:
  1619. X    while (link(buff, filename) < 0) {
  1620. X      long otherpid;
  1621. X    if ((fp = fopen(filename, "r")) == Nullfp) {
  1622. X        log_entry("unable to open %s\n", filename);
  1623. X        if (cron_locking) {
  1624. X        goto Sleep;
  1625. X        }
  1626. X        unlink(buff);
  1627. X        wrap_it_up(1);
  1628. X    }
  1629. X    if (fscanf(fp, "%ld", &otherpid) != 1) { 
  1630. X        log_entry("unable to read pid from %s\n", filename);
  1631. X        fclose(fp);
  1632. X        if (cron_locking) {
  1633. X        goto Sleep;
  1634. X        }
  1635. X        unlink(buff);
  1636. X        wrap_it_up(1);
  1637. X    }
  1638. X    fclose(fp);
  1639. X    if (kill(otherpid, sig) == -1 && errno == ESRCH) {
  1640. X        if (unlink(filename) == -1) {
  1641. X        log_entry("unable to unlink lockfile %s\n", filename);
  1642. X        unlink(buff);
  1643. X        wrap_it_up(1);
  1644. X        }
  1645. X        goto dolink;
  1646. X    }
  1647. X    if (cron_locking) {
  1648. X      Sleep:
  1649. X        sleep(60);
  1650. X        continue;
  1651. X    }
  1652. X    unlink(buff);
  1653. X    return otherpid;
  1654. X    }
  1655. X    unlink(buff);            /* remove temporary LOCK.<pid> file */
  1656. X    locked |= which_lock;
  1657. X    return 0;                /* return success */
  1658. X}
  1659. X
  1660. void
  1661. mt_unlock(which_lock)
  1662. int which_lock;
  1663. X{
  1664. X    which_lock &= locked;
  1665. X    if (which_lock & PASS_LOCK) {
  1666. X    unlink(file_exp(MTLOCK));        /* remove single-pass lock */
  1667. X    }
  1668. X    if (which_lock & DAEMON_LOCK) {
  1669. X    unlink(file_exp(MTDLOCK));        /* remove daemon lock */
  1670. X    }
  1671. X    locked &= ~which_lock;
  1672. X}
  1673. X
  1674. X/* Interpret rn's %x prefixes and ~name expansions without including tons
  1675. X** of useless source.  NOTE:  names that don't start with '/', '%' or '~'
  1676. X** are prefixed with the SPOOL directory.  (Note that ~'s don't work yet.)
  1677. X*/
  1678. char *
  1679. file_exp(name)
  1680. char *name;
  1681. X{
  1682. X    static char namebuf[MAXFILENAME];
  1683. X
  1684. X    if (*name == '/') {    /* fully qualified names are left alone */
  1685. X    return name;
  1686. X    }
  1687. X    switch (name[0]) {
  1688. X    case '%':            /* interpret certain %x values */
  1689. X    switch (name[1]) {
  1690. X    case 'P':
  1691. X        strcpy(namebuf, spool);
  1692. X        break;
  1693. X    case 'w':
  1694. X        strcpy(namebuf, mtlib);
  1695. X        break;
  1696. X    case 'W':
  1697. X        strcpy(namebuf, threaddir);
  1698. X        break;
  1699. X    case 'x':
  1700. X        strcpy(namebuf, lib);
  1701. X        break;
  1702. X    case 'X':
  1703. X        strcpy(namebuf, rnlib);
  1704. X        break;
  1705. X    default:
  1706. X        log_entry("Unknown expansion: %s\n", name);
  1707. X        wrap_it_up(1);
  1708. X    }
  1709. X    strcat(namebuf, name+2);
  1710. X    break;
  1711. X    case '~':
  1712. X    {
  1713. X    char *s = name + 1;
  1714. X
  1715. X    if (!*s || *s == '/') {
  1716. X        sprintf(namebuf, "%s%s", homedir, s);
  1717. X    } else {
  1718. X        log_entry("~name expansions not implemented.");
  1719. X        wrap_it_up(1);
  1720. X    }
  1721. X    }
  1722. X    default:            /* all "normal" names are relative to SPOOL */
  1723. X    sprintf(namebuf, "%s/%s", spool, name);
  1724. X    break;
  1725. X    }
  1726. X    return namebuf;
  1727. X}
  1728. X
  1729. X#ifndef lint
  1730. X/* A malloc that bombs-out when memory is exhausted. */
  1731. char *
  1732. safemalloc(amount)
  1733. MEM_SIZE amount;
  1734. X{
  1735. X    register char *cp;
  1736. X    char *malloc();
  1737. X
  1738. X    if ((cp = malloc(amount)) == Nullch) {
  1739. X    log_error("malloc(%ld) failed.\n", (long)amount);
  1740. X    wrap_it_up(1);
  1741. X    }
  1742. X    return cp;
  1743. X}
  1744. X
  1745. X/* paranoid version of realloc */
  1746. char *
  1747. saferealloc(where,size)
  1748. char *where;
  1749. MEM_SIZE size;
  1750. X{
  1751. X    char *ptr;
  1752. X    char *realloc();
  1753. X
  1754. X    ptr = realloc(where,size?size:1);    /* realloc(0) is NASTY on our system */
  1755. X    if (ptr == Nullch) {
  1756. X    log_error("realloc(..., %ld) failed.\n", (long)size);
  1757. X    wrap_it_up(1);
  1758. X    }
  1759. X    return ptr;
  1760. X}
  1761. X#endif
  1762. X
  1763. X/* Create a malloc'ed copy of a string. */
  1764. char *
  1765. savestr(str)
  1766. char *str;
  1767. X{
  1768. X    register MEM_SIZE len = strlen(str) + 1;
  1769. X    register char *newaddr = safemalloc(len);
  1770. X
  1771. X    bcopy(str, newaddr, (int)len);
  1772. X
  1773. X    return newaddr;
  1774. X}
  1775. X
  1776. X#ifndef lint
  1777. X/* Free some memory if it hasn't already been freed. */
  1778. void
  1779. safefree(pp)
  1780. char **pp;
  1781. X{
  1782. X    if (*pp) {
  1783. X    free(*pp);
  1784. X    *pp = Nullch;
  1785. X    }
  1786. X}
  1787. X#endif
  1788. END_OF_FILE
  1789. if test 4834 -ne `wc -c <'mt-misc.c'`; then
  1790.     echo shar: \"'mt-misc.c'\" unpacked with wrong size!
  1791. fi
  1792. # end of 'mt-misc.c'
  1793. fi
  1794. if test -f 'ndir.c' -a "${1}" != "-c" ; then 
  1795.   echo shar: Will not clobber existing file \"'ndir.c'\"
  1796. else
  1797. echo shar: Extracting \"'ndir.c'\" \(2455 characters\)
  1798. sed "s/^X//" >'ndir.c' <<'END_OF_FILE'
  1799. X/* $Id: ndir.c,v 4.4 1991/09/09 20:23:31 sob Exp sob $
  1800. X *
  1801. X * $Log: ndir.c,v $
  1802. X * Revision 4.4  1991/09/09  20:23:31  sob
  1803. X * release 4.4
  1804. X *
  1805. X *
  1806. X * 
  1807. X */
  1808. X/* This software is Copyright 1991 by Stan Barber. 
  1809. X *
  1810. X * Permission is hereby granted to copy, reproduce, redistribute or otherwise
  1811. X * use this software as long as: there is no monetary profit gained
  1812. X * specifically from the use or reproduction of this software, it is not
  1813. X * sold, rented, traded or otherwise marketed, and this copyright notice is
  1814. X * included prominently in any copy made. 
  1815. X *
  1816. X * The author make no claims as to the fitness or correctness of this software
  1817. X * for any use whatsoever, and it is provided as is. Any use of this software
  1818. X * is at the user's own risk. 
  1819. X */
  1820. X
  1821. X#include "EXTERN.h"
  1822. X#include "common.h"
  1823. X#include "INTERN.h"
  1824. X#include "ndir.h"
  1825. X
  1826. X#ifdef USENDIR
  1827. X/*
  1828. X * support for Berkeley directory reading routine on a V7 file system
  1829. X */
  1830. X
  1831. X/*
  1832. X * open a directory.
  1833. X */
  1834. DIR *
  1835. opendir(name)
  1836. char *name;
  1837. X{
  1838. X    register DIR *dirp;
  1839. X    register int fd;
  1840. X    char *malloc();
  1841. X
  1842. X    if ((fd = open(name, 0)) == -1)
  1843. X        return NULL;
  1844. X    if ((dirp = (DIR *)malloc(sizeof(DIR))) == NULL) {
  1845. X        close (fd);
  1846. X        return NULL;
  1847. X    }
  1848. X    dirp->dd_fd = fd;
  1849. X    dirp->dd_loc = 0;
  1850. X    return dirp;
  1851. X}
  1852. X
  1853. X/*
  1854. X * read an old style directory entry and present it as a new one
  1855. X */
  1856. X#ifndef pyr
  1857. X#define    ODIRSIZ    14
  1858. X
  1859. struct    olddirect {
  1860. X    ino_t    od_ino;
  1861. X    char    od_name[ODIRSIZ];
  1862. X};
  1863. X#else    /* an Pyramid in the ATT universe */
  1864. X#define    ODIRSIZ    248
  1865. X
  1866. struct    olddirect {
  1867. X    long    od_ino;
  1868. X    short    od_fill1, od_fill2;
  1869. X    char    od_name[ODIRSIZ];
  1870. X};
  1871. X#endif
  1872. X
  1873. X/*
  1874. X * get next entry in a directory.
  1875. X */
  1876. struct direct *
  1877. readdir(dirp)
  1878. register DIR *dirp;
  1879. X{
  1880. X    register struct olddirect *dp;
  1881. X    static struct direct dir;
  1882. X
  1883. X    for (;;) {
  1884. X        if (dirp->dd_loc == 0) {
  1885. X            dirp->dd_size = read(dirp->dd_fd, dirp->dd_buf,
  1886. X                DIRBLKSIZ);
  1887. X            if (dirp->dd_size <= 0)
  1888. X                return NULL;
  1889. X        }
  1890. X        if (dirp->dd_loc >= dirp->dd_size) {
  1891. X            dirp->dd_loc = 0;
  1892. X            continue;
  1893. X        }
  1894. X        dp = (struct olddirect *)(dirp->dd_buf + dirp->dd_loc);
  1895. X        dirp->dd_loc += sizeof(struct olddirect);
  1896. X        if (dp->od_ino == 0)
  1897. X            continue;
  1898. X        dir.d_ino = dp->od_ino;
  1899. X        strncpy(dir.d_name, dp->od_name, ODIRSIZ);
  1900. X        dir.d_name[ODIRSIZ] = '\0'; /* insure null termination */
  1901. X        dir.d_namlen = strlen(dir.d_name);
  1902. X        dir.d_reclen = DIRSIZ(&dir);
  1903. X        return (&dir);
  1904. X    }
  1905. X}
  1906. X
  1907. X/*
  1908. X * close a directory.
  1909. X */
  1910. void
  1911. closedir(dirp)
  1912. register DIR *dirp;
  1913. X{
  1914. X    close(dirp->dd_fd);
  1915. X    dirp->dd_fd = -1;
  1916. X    dirp->dd_loc = 0;
  1917. X    free(dirp);
  1918. X}
  1919. X
  1920. X#endif /* USENDIR */
  1921. END_OF_FILE
  1922. if test 2455 -ne `wc -c <'ndir.c'`; then
  1923.     echo shar: \"'ndir.c'\" unpacked with wrong size!
  1924. fi
  1925. # end of 'ndir.c'
  1926. fi
  1927. if test -f 'ndir.h.SH' -a "${1}" != "-c" ; then 
  1928.   echo shar: Will not clobber existing file \"'ndir.h.SH'\"
  1929. else
  1930. echo shar: Extracting \"'ndir.h.SH'\" \(2298 characters\)
  1931. sed "s/^X//" >'ndir.h.SH' <<'END_OF_FILE'
  1932. X: create config.h file
  1933. echo "Extracting ndir.h (with variable substitutions)"
  1934. X. ./config.sh
  1935. X$cat <<EOT >ndir.h
  1936. X/*
  1937. X * This file was produced by running the ndir.h.SH script, which
  1938. X * gets its values from config.sh, which is generally produced by
  1939. X * running Configure.
  1940. X */
  1941. X/* $Id: ndir.h.SH,v 4.4 1991/09/09 20:23:31 sob Exp sob $
  1942. X *
  1943. X * $Log: ndir.h.SH,v $
  1944. X# Revision 4.4  1991/09/09  20:23:31  sob
  1945. X# release 4.4
  1946. X#
  1947. X *
  1948. X * 
  1949. X */
  1950. X/* This software is Copyright 1991 by Stan Barber. 
  1951. X *
  1952. X * Permission is hereby granted to copy, reproduce, redistribute or otherwise
  1953. X * use this software as long as: there is no monetary profit gained
  1954. X * specifically from the use or reproduction of this software, it is not
  1955. X * sold, rented, traded or otherwise marketed, and this copyright notice is
  1956. X * included prominently in any copy made. 
  1957. X *
  1958. X * The author make no claims as to the fitness or correctness of this software
  1959. X * for any use whatsoever, and it is provided as is. Any use of this software
  1960. X * is at the user's own risk. 
  1961. X */
  1962. X
  1963. X#ifdef LIBNDIR
  1964. X#   include <ndir.h>
  1965. X#else
  1966. X#   ifndef USENDIR
  1967. X#    include $dirinc
  1968. X#   else
  1969. X
  1970. X#ifndef DEV_BSIZE
  1971. X#define    DEV_BSIZE    512
  1972. X#endif
  1973. X#define DIRBLKSIZ    DEV_BSIZE
  1974. X#define    MAXNAMLEN    255
  1975. X
  1976. struct    direct {
  1977. X    long    d_ino;            /* inode number of entry */
  1978. X    short    d_reclen;        /* length of this record */
  1979. X    short    d_namlen;        /* length of string in d_name */
  1980. X    char    d_name[MAXNAMLEN + 1];    /* name must be no longer than this */
  1981. X};
  1982. X
  1983. X/*
  1984. X * The DIRSIZ macro gives the minimum record length which will hold
  1985. X * the directory entry.  This requires the amount of space in struct direct
  1986. X * without the d_name field, plus enough space for the name with a terminating
  1987. X * null byte (dp->d_namlen+1), rounded up to a 4 byte boundary.
  1988. X */
  1989. X#undef DIRSIZ
  1990. X#define DIRSIZ(dp) \
  1991. X    ((sizeof (struct direct) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3))
  1992. X
  1993. X/*
  1994. X * Definitions for library routines operating on directories.
  1995. X */
  1996. typedef struct _dirdesc {
  1997. X    int    dd_fd;
  1998. X    long    dd_loc;
  1999. X    long    dd_size;
  2000. X    char    dd_buf[DIRBLKSIZ];
  2001. X} DIR;
  2002. X#ifndef NULL
  2003. X#define NULL 0
  2004. X#endif
  2005. extern    DIR *opendir ANSI((char *));
  2006. extern    struct direct *readdir ANSI((DIR *));
  2007. extern    long telldir ANSI((DIR *));
  2008. extern    void seekdir ANSI((DIR *));
  2009. X#define rewinddir(dirp)    seekdir((dirp), (long)0)
  2010. extern    void closedir ANSI((DIR *));
  2011. X
  2012. X#   endif
  2013. X#endif
  2014. XEOT
  2015. END_OF_FILE
  2016. if test 2298 -ne `wc -c <'ndir.h.SH'`; then
  2017.     echo shar: \"'ndir.h.SH'\" unpacked with wrong size!
  2018. fi
  2019. # end of 'ndir.h.SH'
  2020. fi
  2021. if test -f 'newsetup.1' -a "${1}" != "-c" ; then 
  2022.   echo shar: Will not clobber existing file \"'newsetup.1'\"
  2023. else
  2024. echo shar: Extracting \"'newsetup.1'\" \(2278 characters\)
  2025. sed "s/^X//" >'newsetup.1' <<'END_OF_FILE'
  2026. X.\" $Id: newsetup.1,v 4.4.1.1 1991/09/25 19:36:48 sob Exp sob $
  2027. X.\" 
  2028. X.\" $Log: newsetup.1,v $
  2029. X.\" Revision 4.4.1.1  1991/09/25  19:36:48  sob
  2030. X.\" Changed quote macro to "standard" one
  2031. X.\"
  2032. X.\" Revision 4.4  1991/09/09  20:23:31  sob
  2033. X.\" release 4.4
  2034. X.\"
  2035. X.\"
  2036. X.\" This software is Copyright 1991 by Stan Barber. 
  2037. X.\"
  2038. X.\" Permission is hereby granted to copy, reproduce, redistribute or otherwise
  2039. X.\" use this software as long as: there is no monetary profit gained
  2040. X.\" specifically from the use or reproduction of this software, it is not
  2041. X.\" sold, rented, traded or otherwise marketed, and this copyright notice is
  2042. X.\" included prominently in any copy made. 
  2043. X.\"
  2044. X.\" The author make no claims as to the fitness or correctness of this software
  2045. X.\" for any use whatsoever, and it is provided as is. Any use of this software
  2046. X.\" is at the user's own risk. 
  2047. X.\" 
  2048. X.\" 
  2049. X.de Sh
  2050. X.br
  2051. X.ne 5
  2052. X.PP
  2053. X\fB\\$1\fR
  2054. X.PP
  2055. X..
  2056. X.de Sp
  2057. X.if t .sp .5v
  2058. X.if n .sp
  2059. X..
  2060. X.\"
  2061. X.\"     Set up \*(-- to give an unbreakable dash;
  2062. X.\"     string Tr holds user defined translation string.
  2063. X.\"     Bell System Logo is used as a dummy character.
  2064. X.\"
  2065. X.ie n \{\
  2066. X.tr \(bs-\*(Tr
  2067. X.ds -- \(bs-
  2068. X.if (\n(.H=4u)&(1m=24u) .ds -- \(bs\h'-12u'\(bs\h'-12u'-\" diablo 10 pitch
  2069. X.if (\n(.H=4u)&(1m=20u) .ds -- \(bs\h'-12u'\(bs\h'-8u'-\" diablo 12 pitch
  2070. X.ds L" ""
  2071. X.ds R" ""
  2072. X.ds L' '
  2073. X.ds R' '
  2074. X'br\}
  2075. X.el\{\
  2076. X.ds -- \(em\|
  2077. X.tr \*(Tr
  2078. X.ds L" ``
  2079. X.ds R" ''
  2080. X.ds L' `
  2081. X.ds R' '
  2082. X'br\}
  2083. X.TH NEWSETUP 1 LOCAL
  2084. X.SH NAME
  2085. newsetup - a program to set up a .newsrc file
  2086. X.SH SYNOPSIS
  2087. X.B newsetup
  2088. X.SH DESCRIPTION
  2089. The
  2090. X.I newsetup
  2091. program creates a new .newsrc file containing all of the currently active
  2092. newsgroups.
  2093. It tries to put them in a reasonable order, i.e. local newsgroups earlier,
  2094. but you'll probably want to change the ordering anyway (if you use
  2095. X.IR rn )
  2096. in order to put interesting newsgroups first.
  2097. If you already have a .newsrc, it will be backed up with the name
  2098. X\*(L".oldnewsrc\*(R".
  2099. X.SH ENVIRONMENT
  2100. X.IP DOTDIR 8
  2101. Where to put your .newsrc, if not in your home directory.
  2102. X.Sp
  2103. Default: $HOME
  2104. X.IP HOME 8
  2105. Your home directory.
  2106. X.Sp
  2107. Default: $LOGDIR
  2108. X.IP LOGDIR 8
  2109. Your home directory if HOME is undefined.
  2110. X.SH FILES
  2111. X/usr/lib/news/active or a reasonable facsimile
  2112. X.br
  2113. X${DOTDIR-{$HOME-$LOGDIR}}/.newsrc
  2114. X.SH SEE ALSO
  2115. rn(1), newsrc(5)
  2116. X.SH DIAGNOSTICS
  2117. X.SH BUGS
  2118. END_OF_FILE
  2119. if test 2278 -ne `wc -c <'newsetup.1'`; then
  2120.     echo shar: \"'newsetup.1'\" unpacked with wrong size!
  2121. fi
  2122. # end of 'newsetup.1'
  2123. fi
  2124. if test -f 'newsetup.SH' -a "${1}" != "-c" ; then 
  2125.   echo shar: Will not clobber existing file \"'newsetup.SH'\"
  2126. else
  2127. echo shar: Extracting \"'newsetup.SH'\" \(3286 characters\)
  2128. sed "s/^X//" >'newsetup.SH' <<'END_OF_FILE'
  2129. case $CONFIG in
  2130. X    '') . ./config.sh ;;
  2131. esac
  2132. echo "Extracting newsetup (with variable substitutions)"
  2133. X$spitshell >newsetup <<!GROK!THIS!
  2134. X$startsh
  2135. X#
  2136. X# $Id: newsetup.SH,v 4.4.2.1 1991/12/01 18:05:42 sob PATCH_2 sob $
  2137. X# 
  2138. X# $Log: newsetup.SH,v $
  2139. X# Revision 4.4.2.1  1991/12/01  18:05:42  sob
  2140. X# Fixed problems with CTRLA flag.
  2141. X#
  2142. X# Revision 4.4.1.2  1991/11/09  20:54:14  sob
  2143. X# Changes from eggert@twinsun.com to get rid of old code.
  2144. X#
  2145. X# Revision 4.4.1.1  1991/09/25  19:38:08  sob
  2146. X# various fixed
  2147. X#
  2148. X# Revision 4.4  1991/09/09  20:23:31  sob
  2149. X# release 4.4
  2150. X#
  2151. X#
  2152. X# 
  2153. X# This software is Copyright 1991 by Stan Barber. 
  2154. X#
  2155. X# Permission is hereby granted to copy, reproduce, redistribute or otherwise
  2156. X# use this software as long as: there is no monetary profit gained
  2157. X# specifically from the use or reproduction of this software, it is not
  2158. X# sold, rented, traded or otherwise marketed, and this copyright notice is
  2159. X# included prominently in any copy made. 
  2160. X#
  2161. X# The author make no claims as to the fitness or correctness of this software
  2162. X# for any use whatsoever, and it is provided as is. Any use of this software
  2163. X# is at the user's own risk. 
  2164. X
  2165. export PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh \$0; kill \$\$)
  2166. X
  2167. X: syntax: newsetup
  2168. X
  2169. X: System dependencies
  2170. X: You will want to change the definitions below to reflect the distribution
  2171. X: areas around you.  If you have more areas than this you will need to modify
  2172. X: the sed below.
  2173. X
  2174. locorg="$locpref"
  2175. organization="$orgpref"
  2176. city="$citypref"
  2177. state="$statepref"
  2178. cntry="$cntrypref"
  2179. cont="$contpref"
  2180. X#NORMALactive="${active-/usr/lib/news/active}"
  2181. X#NNTPactive="/tmp/active.\$\$"
  2182. X
  2183. dotdir="\${DOTDIR-\${HOME-\$LOGDIR}}"
  2184. newsrc="\${NEWSRC-\$dotdir/.newsrc}"
  2185. X$rm -f \$newsrc-old
  2186. X$echo "Creating \$newsrc to be used by news programs."
  2187. X#NNTPrnlib=$rnlib
  2188. X#NNTPcase \$rnlib in
  2189. X#NNTP~*) rnlib=\`$filexp \$rnlib\` ;;
  2190. X#NNTPesac
  2191. X#NNTPif \$rnlib/getactive ACTIVE \$active; then
  2192. X#NNTP    true;
  2193. X#NNTPelse
  2194. X#NNTP    exit 1;
  2195. X#NNTPfi
  2196. X#NORMALcase \$active in
  2197. X#NORMAL~*) active=\`$filexp \$active\` ;;
  2198. X#NORMALesac
  2199. X
  2200. if $test -s \$newsrc ; then
  2201. X    $echo "Saving your current \$newsrc as \$newsrc-old..."
  2202. X    $mv -f \$newsrc \$newsrc-old
  2203. fi
  2204. X
  2205. X: newsrc order determined here
  2206. X
  2207. X$sed <\$active '
  2208. X    /^to\./d
  2209. X    / [^mny][^ ]*$/d
  2210. X    s/ .*//
  2211. X    s/^/ /
  2212. X    s/^ '\$locorg'\./01&/
  2213. X    s/^ '\$organization'\./02&/
  2214. X    s/^ '\$city'\./03&/
  2215. X    s/^ '\$state'\./04&/
  2216. X    s/^ '\$cntry'\./05&/
  2217. X    s/^ '\$cont'\./06&/
  2218. X    s/^ news\./07&/
  2219. X    s/^ comp\./08&/
  2220. X    s/^ sci\./09&/
  2221. X    s/^ rec\./10&/
  2222. X    s/^ soc\./11&/
  2223. X    s/^ talk\./13&/
  2224. X    s/^ control\$/14&/
  2225. X    s/^ junk\$/14&/
  2226. X    s/^ test\$/14&/
  2227. X    /\.test\$/s/^[0-9]*/14/
  2228. X    s/^ .*\./12&/
  2229. X    s/^ /00&/
  2230. X' |
  2231. X$sort -u |
  2232. X$sed '
  2233. X    /^14 /!s/\$/:/
  2234. X    /^14 /s/\$/!/
  2235. X    s/^[0-9][0-9] //
  2236. X' >\$newsrc
  2237. X
  2238. X#NNTP$rm -f \$active
  2239. X
  2240. X$cat <<'EOH'
  2241. Done.
  2242. X
  2243. If you have never used the news system before, you may find the articles
  2244. in news.announce.newusers to be helpful.  There is also a manual entry for rn.
  2245. X
  2246. To get rid of newsgroups you aren't interested in, use the 'u' command.
  2247. Type h for help at any time while running rn.
  2248. XEOH
  2249. X!GROK!THIS!
  2250. case "$isrrn" in
  2251. define)  sed < newsetup -e '/^#NNTP/s/^#NNTP//' -e '/^#NORMAL/d' > newsetup.new ;;
  2252. X*) sed < newsetup -e '/^#NNTP/d' -e '/^#NORMAL/s/^#NORMAL//' > newsetup.new ;;
  2253. esac
  2254. mv newsetup.new newsetup
  2255. X$eunicefix newsetup
  2256. chmod 755 newsetup
  2257. END_OF_FILE
  2258. if test 3286 -ne `wc -c <'newsetup.SH'`; then
  2259.     echo shar: \"'newsetup.SH'\" unpacked with wrong size!
  2260. fi
  2261. # end of 'newsetup.SH'
  2262. fi
  2263. if test -f 'newsgroups.1' -a "${1}" != "-c" ; then 
  2264.   echo shar: Will not clobber existing file \"'newsgroups.1'\"
  2265. else
  2266. echo shar: Extracting \"'newsgroups.1'\" \(2385 characters\)
  2267. sed "s/^X//" >'newsgroups.1' <<'END_OF_FILE'
  2268. X.\" $Id: newsgroups.1,v 4.4.1.1 1991/09/25 19:36:48 sob Exp sob $
  2269. X.\" 
  2270. X.\" $Log: newsgroups.1,v $
  2271. X.\" Revision 4.4.1.1  1991/09/25  19:36:48  sob
  2272. X.\" Changed quote macro to "standard" one
  2273. X.\"
  2274. X.\" Revision 4.4  1991/09/09  20:23:31  sob
  2275. X.\" release 4.4
  2276. X.\"
  2277. X.\"
  2278. X.\" This software is Copyright 1991 by Stan Barber. 
  2279. X.\"
  2280. X.\" Permission is hereby granted to copy, reproduce, redistribute or otherwise
  2281. X.\" use this software as long as: there is no monetary profit gained
  2282. X.\" specifically from the use or reproduction of this software, it is not
  2283. X.\" sold, rented, traded or otherwise marketed, and this copyright notice is
  2284. X.\" included prominently in any copy made. 
  2285. X.\"
  2286. X.\" The author make no claims as to the fitness or correctness of this software
  2287. X.\" for any use whatsoever, and it is provided as is. Any use of this software
  2288. X.\" is at the user's own risk. 
  2289. X.\" 
  2290. X.\" 
  2291. X.de Sh
  2292. X.br
  2293. X.ne 5
  2294. X.PP
  2295. X\fB\\$1\fR
  2296. X.PP
  2297. X..
  2298. X.de Sp
  2299. X.if t .sp .5v
  2300. X.if n .sp
  2301. X..
  2302. X.\"
  2303. X.\"     Set up \*(-- to give an unbreakable dash;
  2304. X.\"     string Tr holds user defined translation string.
  2305. X.\"     Bell System Logo is used as a dummy character.
  2306. X.\"
  2307. X.ie n \{\
  2308. X.tr \(bs-\*(Tr
  2309. X.ds -- \(bs-
  2310. X.if (\n(.H=4u)&(1m=24u) .ds -- \(bs\h'-12u'\(bs\h'-12u'-\" diablo 10 pitch
  2311. X.if (\n(.H=4u)&(1m=20u) .ds -- \(bs\h'-12u'\(bs\h'-8u'-\" diablo 12 pitch
  2312. X.ds L" ""
  2313. X.ds R" ""
  2314. X.ds L' '
  2315. X.ds R' '
  2316. X'br\}
  2317. X.el\{\
  2318. X.ds -- \(em\|
  2319. X.tr \*(Tr
  2320. X.ds L" ``
  2321. X.ds R" ''
  2322. X.ds L' `
  2323. X.ds R' '
  2324. X'br\}
  2325. X.TH NEWSGROUPS 1 LOCAL
  2326. X.SH NAME
  2327. newsgroups - a program to list unsubscribed newsgroups.
  2328. X.SH SYNOPSIS
  2329. X.B newsgroups pattern flag
  2330. X.SH DESCRIPTION
  2331. The
  2332. X.I newsgroups
  2333. program compares your .newsrc file with the file of active newsgroups,
  2334. and prints a list of unsubscribed newsgroups matching pattern.
  2335. If the second argument \*(L"flag\*(R" is present, only newsgroups not
  2336. found in your .newsrc are listed, and the display is not paged.
  2337. If the second argument is missing, the display is paged, and an additional
  2338. list of unsubscribed newsgroups occurring in your .newsrc is printed.
  2339. X.SH ENVIRONMENT
  2340. X.IP DOTDIR 8
  2341. Where to find your .newsrc, if not in your home directory.
  2342. X.Sp
  2343. Default: $HOME
  2344. X.IP HOME 8
  2345. Your home directory.
  2346. X.Sp
  2347. Default: $LOGDIR
  2348. X.IP LOGDIR 8
  2349. Your home directory if HOME is undefined.
  2350. X.SH FILES
  2351. X/usr/lib/news/active or a reasonable facsimile
  2352. X.br
  2353. X${DOTDIR-{$HOME-$LOGDIR}}/.newsrc
  2354. X.SH SEE ALSO
  2355. rn(1), newsrc(5)
  2356. X.SH DIAGNOSTICS
  2357. X.SH BUGS
  2358. The flag argument is a kludge.
  2359. END_OF_FILE
  2360. if test 2385 -ne `wc -c <'newsgroups.1'`; then
  2361.     echo shar: \"'newsgroups.1'\" unpacked with wrong size!
  2362. fi
  2363. # end of 'newsgroups.1'
  2364. fi
  2365. if test -f 'newsgroups.SH' -a "${1}" != "-c" ; then 
  2366.   echo shar: Will not clobber existing file \"'newsgroups.SH'\"
  2367. else
  2368. echo shar: Extracting \"'newsgroups.SH'\" \(2780 characters\)
  2369. sed "s/^X//" >'newsgroups.SH' <<'END_OF_FILE'
  2370. case $CONFIG in
  2371. X    '') . ./config.sh ;;
  2372. esac
  2373. echo "Extracting newsgroups (with variable substitutions)"
  2374. X$spitshell >newsgroups <<!GROK!THIS!
  2375. X$startsh
  2376. X# $Id: newsgroups.SH,v 4.4.2.1 1991/12/01 18:05:42 sob PATCH_2 sob $
  2377. X# 
  2378. X# $Log: newsgroups.SH,v $
  2379. X# Revision 4.4.2.1  1991/12/01  18:05:42  sob
  2380. X# Patchlevel 2 changes
  2381. X#
  2382. X# Revision 4.4.1.1  1991/09/25  19:38:08  sob
  2383. X# various fixed
  2384. X#
  2385. X# Revision 4.4  1991/09/09  20:23:31  sob
  2386. X# release 4.4
  2387. X#
  2388. X# 
  2389. X# This software is Copyright 1991 by Stan Barber. 
  2390. X#
  2391. X# Permission is hereby granted to copy, reproduce, redistribute or otherwise
  2392. X# use this software as long as: there is no monetary profit gained
  2393. X# specifically from the use or reproduction of this software, it is not
  2394. X# sold, rented, traded or otherwise marketed, and this copyright notice is
  2395. X# included prominently in any copy made. 
  2396. X#
  2397. X# The author make no claims as to the fitness or correctness of this software
  2398. X# for any use whatsoever, and it is provided as is. Any use of this software
  2399. X# is at the user's own risk. 
  2400. X
  2401. export PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh \$0; kill \$\$)
  2402. X
  2403. X: syntax: newsgroups [pattern] [pipeflag]
  2404. X
  2405. X: System Dependencies
  2406. X
  2407. X: You might want to change pager to a "make column" program if you have one.
  2408. X: On the other hand, if your kernel does paging, cat would probably do.
  2409. pager="${pager-/usr/ucb/more}"
  2410. X#NORMALactive="${active-/usr/lib/news/active}"
  2411. X
  2412. X#NORMALcase \$active in
  2413. X#NORMAL~*) active=\`$filexp \$active\` ;;
  2414. X#NORMALesac
  2415. X
  2416. X#NNTPactive="/tmp/active.\$\$"
  2417. X
  2418. X#NNTPcase \$rnlib in
  2419. X#NNTP~*) rnlib=\`$filexp \$rnlib\` ;;
  2420. X#NNTPesac
  2421. X
  2422. X: End of system dependencies, hopefully
  2423. X
  2424. X#NNTPif $rnlib/getactive ACTIVE \$active; then
  2425. X#NNTP    true;
  2426. X#NNTPelse
  2427. X#NNTP    exit 1;
  2428. X#NNTPfi
  2429. X
  2430. if $test \$# -ge 2 ; then
  2431. X    pager=$cat
  2432. else
  2433. X    $echo "Completely unsubscribed newsgroups:"
  2434. fi
  2435. X
  2436. dotdir=\${DOTDIR-\${HOME-\$LOGDIR}}
  2437. newsrc=\${NEWSRC-\$dotdir/.newsrc}
  2438. X
  2439. X: Throwing .newsrc into the pot twice is a lovely hack to prevent
  2440. X: bogus newsgroups from showing up as unsubscribed.
  2441. X
  2442. X$cat \$newsrc \$newsrc \$active | \\
  2443. X$sed -n    -e '/^options/d' \\
  2444. X    -e '/^[     ]/d' \\
  2445. X    -e '/^control/d' \\
  2446. X    -e '/^to\./d' \\
  2447. X     -e '/ x\$/d' \\
  2448. X    -e 's/^\([^ !:]*\)[ !:].*\$/\1/' \\
  2449. X    -e "/.*\$1/p" | \\
  2450. X$sort | $uniq -u | \$pager
  2451. X#NNTP$rm -f \$active
  2452. if $test \$# -ge 2 ; then
  2453. X    exit
  2454. fi
  2455. X$echo $n "[Type return to continue] $c"
  2456. read tmp
  2457. X$echo ""
  2458. X$echo "Unsubscribed but mentioned in \$newsrc:"
  2459. X$sed -n < \$newsrc \\
  2460. X    -e "/\$1.*!/"'s/^\([^!]*\)!.*\$/\1/p' | \\
  2461. X$sort | \$pager
  2462. X!GROK!THIS!
  2463. case "$isrrn" in
  2464. define)  sed < newsgroups -e '/^#NNTP/s/^#NNTP//' -e '/^#NORMAL/d' > newsgroups.new ;;
  2465. X*) sed < newsgroups -e '/^#NNTP/d' -e '/^#NORMAL/s/^#NORMAL//' > newsgroups.new ;;
  2466. esac
  2467. mv newsgroups.new newsgroups
  2468. X$eunicefix newsgroups
  2469. chmod 755 newsgroups
  2470. END_OF_FILE
  2471. if test 2780 -ne `wc -c <'newsgroups.SH'`; then
  2472.     echo shar: \"'newsgroups.SH'\" unpacked with wrong size!
  2473. fi
  2474. # end of 'newsgroups.SH'
  2475. fi
  2476. if test -f 'newsnews.SH' -a "${1}" != "-c" ; then 
  2477.   echo shar: Will not clobber existing file \"'newsnews.SH'\"
  2478. else
  2479. echo shar: Extracting \"'newsnews.SH'\" \(2161 characters\)
  2480. sed "s/^X//" >'newsnews.SH' <<'END_OF_FILE'
  2481. X: see end of file for revision information
  2482. case $CONFIG in
  2483. X    '') . ./config.sh ;;
  2484. esac
  2485. echo "Extracting newsnews (with variable substitutions)"
  2486. cat >newsnews <<!GROK!THIS!
  2487. X            *** NEWS NEWS ***
  2488. X
  2489. Welcome to trn.  There are more options to trn than you want to think about, so
  2490. we won't list them here.  If you want to find out about them, read the manual
  2491. page(s).  There are some important things to remember, though:
  2492. X
  2493. X  * Trn is an extention of rn.  Where possible, the command syntax is the same.
  2494. X  * To access all the new features, specify the options -x and -X.  These
  2495. X    options MAY be on by default, but it won't hurt to be redundant.
  2496. X  * Trn runs in cbreak mode.  This means you don't have to type carriage return
  2497. X    on single character commands.  (There are some multi-character commands.)
  2498. X  * At ANY prompt, you may type 'h' for help.  There are many different help
  2499. X    menus, depending on the context.  Also, typing <esc>h in the middle of a
  2500. X    multi-character command will list escape substitutions.
  2501. X  * Typing a space to any prompt means to do the normal thing.  You could
  2502. X    spend all day reading news and never hit anything but the space bar.
  2503. X
  2504. This particular message comes from $rnlib/newsnews, and will only
  2505. appear once.  If your news administrator puts a new message in here, it
  2506. will be displayed for you the first time you run trn after the change.
  2507. X
  2508. Wayne Davison    davison@borland.com
  2509. X!GROK!THIS!
  2510. X$eunicefix newsnews
  2511. X#
  2512. X# $Id: newsnews.SH,v 4.4 1991/09/09 20:23:31 sob Exp sob $
  2513. X# 
  2514. X# $Log: newsnews.SH,v $
  2515. X# Revision 4.4  1991/09/09  20:23:31  sob
  2516. X# release 4.4
  2517. X#
  2518. X#
  2519. X#
  2520. X# This software is Copyright 1991 by Stan Barber. 
  2521. X#
  2522. X# Permission is hereby granted to copy, reproduce, redistribute or otherwise
  2523. X# use this software as long as: there is no monetary profit gained
  2524. X# specifically from the use or reproduction of this software, it is not
  2525. X# sold, rented, traded or otherwise marketed, and this copyright notice is
  2526. X# included prominently in any copy made. 
  2527. X#
  2528. X# The author make no claims as to the fitness or correctness of this software
  2529. X# for any use whatsoever, and it is provided as is. Any use of this software
  2530. X# is at the user's own risk. 
  2531. X
  2532. END_OF_FILE
  2533. if test 2161 -ne `wc -c <'newsnews.SH'`; then
  2534.     echo shar: \"'newsnews.SH'\" unpacked with wrong size!
  2535. fi
  2536. # end of 'newsnews.SH'
  2537. fi
  2538. if test -f 'ngsrch.c' -a "${1}" != "-c" ; then 
  2539.   echo shar: Will not clobber existing file \"'ngsrch.c'\"
  2540. else
  2541. echo shar: Extracting \"'ngsrch.c'\" \(3430 characters\)
  2542. sed "s/^X//" >'ngsrch.c' <<'END_OF_FILE'
  2543. X/* $Id: ngsrch.c,v 4.4 1991/09/09 20:23:31 sob Exp sob $
  2544. X *
  2545. X * $Log: ngsrch.c,v $
  2546. X * Revision 4.4  1991/09/09  20:23:31  sob
  2547. X * release 4.4
  2548. X *
  2549. X *
  2550. X * 
  2551. X */
  2552. X/* This software is Copyright 1991 by Stan Barber. 
  2553. X *
  2554. X * Permission is hereby granted to copy, reproduce, redistribute or otherwise
  2555. X * use this software as long as: there is no monetary profit gained
  2556. X * specifically from the use or reproduction of this software, it is not
  2557. X * sold, rented, traded or otherwise marketed, and this copyright notice is
  2558. X * included prominently in any copy made. 
  2559. X *
  2560. X * The author make no claims as to the fitness or correctness of this software
  2561. X * for any use whatsoever, and it is provided as is. Any use of this software
  2562. X * is at the user's own risk. 
  2563. X */
  2564. X
  2565. X#include "EXTERN.h"
  2566. X#include "common.h"
  2567. X#include "rcstuff.h"
  2568. X#include "final.h"
  2569. X#include "search.h"
  2570. X#include "rn.h"
  2571. X#include "util.h"
  2572. X#include "term.h"
  2573. X#include "rcln.h"
  2574. X#include "INTERN.h"
  2575. X#include "ngsrch.h"
  2576. X
  2577. X#ifdef NGSORONLY
  2578. X    COMPEX ngcompex;
  2579. X#endif
  2580. X
  2581. void
  2582. ngsrch_init()
  2583. X{
  2584. X#ifdef ZEROGLOB
  2585. X    init_compex(&ngcompex);
  2586. X#endif    /* ZEROGLOB */
  2587. X    ;
  2588. X}
  2589. X
  2590. X#ifdef NGSEARCH
  2591. int
  2592. ng_search(patbuf,get_cmd)
  2593. char *patbuf;                /* if patbuf != buf, get_cmd must */
  2594. int get_cmd;                /*   be set to FALSE!!! */
  2595. X{
  2596. X    char *pattern;            /* unparsed pattern */
  2597. X    register char cmdchr = *patbuf;    /* what kind of search? */
  2598. X    register char *s;
  2599. X    bool backward = cmdchr == '?';    /* direction of search */
  2600. X
  2601. X    int_count = 0;
  2602. X    if (get_cmd && buf == patbuf)
  2603. X    if (!finish_command(FALSE))        /* get rest of command */
  2604. X        return NGS_ABORT;
  2605. X    for (pattern = patbuf+1; *pattern == ' '; pattern++) ;
  2606. X    if (*pattern) {
  2607. X    ng_doread = FALSE;
  2608. X    }
  2609. X    s = rindex(pattern,cmdchr);
  2610. X    if (s != Nullch && *(s-1) != '\\') {
  2611. X    *s++ = '\0';
  2612. X    if (index(s,'r') != Nullch)
  2613. X        ng_doread = TRUE;
  2614. X    }
  2615. X    if ((s = ng_comp(&ngcompex,pattern,TRUE,TRUE)) != Nullch) {
  2616. X                    /* compile regular expression */
  2617. X    printf("\n%s\n",s) FLUSH;
  2618. X    return NGS_ERROR;
  2619. X    }
  2620. X    fputs("\nSearching...",stdout) FLUSH;    /* give them something to read */
  2621. X    fflush(stdout);
  2622. X    for (;;) {
  2623. X    if (int_count) {
  2624. X        int_count = 0;
  2625. X        return NGS_INTR;
  2626. X    }
  2627. X    if (backward) {
  2628. X        if (ng > 0)
  2629. X        --ng;
  2630. X        else
  2631. X        ng = nextrcline;
  2632. X    }
  2633. X    else {
  2634. X        if (ng >= nextrcline)
  2635. X        ng = 0;
  2636. X        else
  2637. X        ++ng;
  2638. X    }
  2639. X    if (ng == current_ng)
  2640. X        return NGS_NOTFOUND;
  2641. X    if (ng == nextrcline || toread[ng] < TR_NONE || !ng_wanted())
  2642. X        continue;
  2643. X    if (toread[ng] == TR_NONE)
  2644. X        set_toread(ng);
  2645. X    
  2646. X    if (toread[ng] > TR_NONE)
  2647. X        return NGS_FOUND;
  2648. X    else if (toread[ng] == TR_NONE)
  2649. X        if (ng_doread)
  2650. X        return NGS_FOUND;
  2651. X        else
  2652. X        printf("\n[0 unread in %s--skipping]",rcline[ng]) FLUSH;
  2653. X    }
  2654. X}
  2655. X
  2656. bool
  2657. ng_wanted()
  2658. X{
  2659. X    return execute(&ngcompex,rcline[ng]) != Nullch;
  2660. X}
  2661. X#endif
  2662. X
  2663. X#ifdef NGSORONLY
  2664. char *
  2665. ng_comp(compex,pattern,RE,fold)
  2666. COMPEX *compex;
  2667. char *pattern;
  2668. bool_int RE;
  2669. bool_int fold;
  2670. X{
  2671. X    char ng_pattern[128];
  2672. X    register char *s = pattern, *d = ng_pattern;
  2673. X
  2674. X    if (!*s) {
  2675. X    if(compex->expbuf)
  2676. X        return Nullch;            /* reuse old pattern */
  2677. X    else
  2678. X        return "No previous search pattern";
  2679. X    }
  2680. X    for (; *s; s++) {
  2681. X    if (*s == '.') {
  2682. X        *d++ = '\\';
  2683. X        *d++ = *s;
  2684. X    }
  2685. X    else if (*s == '?') {
  2686. X        *d++ = '.';
  2687. X    }
  2688. X    else if (*s == '*') {
  2689. X        *d++ = '.';
  2690. X        *d++ = *s;
  2691. X    }
  2692. X    else if (strnEQ(s,"all",3)) {
  2693. X        *d++ = '.';
  2694. X        *d++ = '*';
  2695. X        s += 2;
  2696. X    }
  2697. X    else
  2698. X        *d++ = *s;
  2699. X    }
  2700. X    *d = '\0';
  2701. X    return compile(compex,ng_pattern,RE,fold);
  2702. X}
  2703. X#endif
  2704. X
  2705. END_OF_FILE
  2706. if test 3430 -ne `wc -c <'ngsrch.c'`; then
  2707.     echo shar: \"'ngsrch.c'\" unpacked with wrong size!
  2708. fi
  2709. # end of 'ngsrch.c'
  2710. fi
  2711. if test -f 'only.c' -a "${1}" != "-c" ; then 
  2712.   echo shar: Will not clobber existing file \"'only.c'\"
  2713. else
  2714. echo shar: Extracting \"'only.c'\" \(2852 characters\)
  2715. sed "s/^X//" >'only.c' <<'END_OF_FILE'
  2716. X/* $Id: only.c,v 4.4 1991/09/09 20:23:31 sob Exp sob $
  2717. X *
  2718. X * $Log: only.c,v $
  2719. X * Revision 4.4  1991/09/09  20:23:31  sob
  2720. X * release 4.4
  2721. X *
  2722. X *
  2723. X * 
  2724. X */
  2725. X/* This software is Copyright 1991 by Stan Barber. 
  2726. X *
  2727. X * Permission is hereby granted to copy, reproduce, redistribute or otherwise
  2728. X * use this software as long as: there is no monetary profit gained
  2729. X * specifically from the use or reproduction of this software, it is not
  2730. X * sold, rented, traded or otherwise marketed, and this copyright notice is
  2731. X * included prominently in any copy made. 
  2732. X *
  2733. X * The author make no claims as to the fitness or correctness of this software
  2734. X * for any use whatsoever, and it is provided as is. Any use of this software
  2735. X * is at the user's own risk. 
  2736. X */
  2737. X
  2738. X#include "EXTERN.h"
  2739. X#include "common.h"
  2740. X#include "search.h"
  2741. X#include "util.h"
  2742. X#include "final.h"
  2743. X#include "ngsrch.h"
  2744. X#include "INTERN.h"
  2745. X#include "only.h"
  2746. X
  2747. void
  2748. only_init()
  2749. X{
  2750. X    ;
  2751. X}
  2752. X
  2753. void
  2754. setngtodo(pat)
  2755. char *pat;
  2756. X{
  2757. X    char *s;
  2758. X
  2759. X#ifdef ONLY
  2760. X    if (!*pat)
  2761. X    return;
  2762. X    if (maxngtodo < NGMAX) {
  2763. X    ngtodo[maxngtodo] = savestr(pat);
  2764. X#ifdef SPEEDOVERMEM
  2765. X#ifndef lint
  2766. X    compextodo[maxngtodo] = (COMPEX*)safemalloc(sizeof(COMPEX));
  2767. X#endif /* lint */
  2768. X    init_compex(compextodo[maxngtodo]);
  2769. X    compile(compextodo[maxngtodo],pat,TRUE,TRUE);
  2770. X    if ((s = ng_comp(compextodo[maxngtodo],pat,TRUE,TRUE)) != Nullch) {
  2771. X                        /* compile regular expression */
  2772. X        printf("\n%s\n",s) FLUSH;
  2773. X        finalize(1);
  2774. X    }
  2775. X#endif
  2776. X    maxngtodo++;
  2777. X    }
  2778. X#else
  2779. X    notincl("o");
  2780. X#endif
  2781. X}
  2782. X
  2783. X/* if command line list is non-null, is this newsgroup wanted? */
  2784. X
  2785. bool
  2786. inlist(ngnam)
  2787. char *ngnam;
  2788. X{
  2789. X#ifdef ONLY
  2790. X    register int i;
  2791. X#ifdef SPEEDOVERMEM
  2792. X
  2793. X    if (maxngtodo == 0)
  2794. X    return TRUE;
  2795. X    for (i=0; i<maxngtodo; i++) {
  2796. X    if (execute(compextodo[i],ngnam))
  2797. X        return TRUE;
  2798. X    }
  2799. X    return FALSE;
  2800. X#else
  2801. X    COMPEX ilcompex;
  2802. X    char *s;
  2803. X
  2804. X    if (maxngtodo == 0)
  2805. X    return TRUE;
  2806. X    init_compex(&ilcompex);
  2807. X    for (i=0; i<maxngtodo; i++) {
  2808. X    if ((s = ng_comp(&ilcompex,ngtodo[i],TRUE,TRUE)) != Nullch) {
  2809. X                        /* compile regular expression */
  2810. X        printf("\n%s\n",s) FLUSH;
  2811. X        finalize(1);
  2812. X    }
  2813. X    
  2814. X    if (execute(&ilcompex,ngnam) != Nullch) {
  2815. X        free_compex(&ilcompex);
  2816. X        return TRUE;
  2817. X    }
  2818. X    }
  2819. X    free_compex(&ilcompex);
  2820. X    return FALSE;
  2821. X#endif
  2822. X#else
  2823. X    return TRUE;
  2824. X#endif
  2825. X}
  2826. X
  2827. X#ifdef ONLY
  2828. void
  2829. end_only()
  2830. X{
  2831. X    if (maxngtodo) {            /* did they specify newsgroup(s) */
  2832. X    int whicharg;
  2833. X
  2834. X#ifdef VERBOSE
  2835. X    IF(verbose)
  2836. X        printf("\nRestriction %s%s removed.\n",ngtodo[0],
  2837. X        maxngtodo > 1 ? ", etc." : nullstr) FLUSH;
  2838. X    ELSE
  2839. X#endif
  2840. X#ifdef TERSE
  2841. X        fputs("\nExiting \"only\".\n",stdout) FLUSH;
  2842. X#endif
  2843. X    for (whicharg = 0; whicharg < maxngtodo; whicharg++) {
  2844. X        free(ngtodo[whicharg]);
  2845. X#ifdef SPEEDOVERMEM
  2846. X        free_compex(compextodo[whicharg]);
  2847. X#ifndef lint
  2848. X        free((char*)compextodo[whicharg]);
  2849. X#endif /* lint */
  2850. X#endif
  2851. X    }
  2852. X    maxngtodo = 0;
  2853. X    }
  2854. X}
  2855. X#endif
  2856. END_OF_FILE
  2857. if test 2852 -ne `wc -c <'only.c'`; then
  2858.     echo shar: \"'only.c'\" unpacked with wrong size!
  2859. fi
  2860. # end of 'only.c'
  2861. fi
  2862. if test -f 'rcstuff.h' -a "${1}" != "-c" ; then 
  2863.   echo shar: Will not clobber existing file \"'rcstuff.h'\"
  2864. else
  2865. echo shar: Extracting \"'rcstuff.h'\" \(2263 characters\)
  2866. sed "s/^X//" >'rcstuff.h' <<'END_OF_FILE'
  2867. X/* $Id: rcstuff.h,v 4.4.2.1 1991/12/01 18:05:42 sob PATCH_2 sob $
  2868. X *
  2869. X * $Log: rcstuff.h,v $
  2870. X * Revision 4.4.2.1  1991/12/01  18:05:42  sob
  2871. X * Patchlevel 2 changes
  2872. X *
  2873. X * Revision 4.4  1991/09/09  20:27:37  sob
  2874. X * release 4.4
  2875. X *
  2876. X *
  2877. X * 
  2878. X */
  2879. X/* This software is Copyright 1991 by Stan Barber. 
  2880. X *
  2881. X * Permission is hereby granted to copy, reproduce, redistribute or otherwise
  2882. X * use this software as long as: there is no monetary profit gained
  2883. X * specifically from the use or reproduction of this software, it is not
  2884. X * sold, rented, traded or otherwise marketed, and this copyright notice is
  2885. X * included prominently in any copy made. 
  2886. X *
  2887. X * The author make no claims as to the fitness or correctness of this software
  2888. X * for any use whatsoever, and it is provided as is. Any use of this software
  2889. X * is at the user's own risk. 
  2890. X */
  2891. X
  2892. XEXT char **rcline INIT(NULL);/* pointers to lines of .newsrc */
  2893. XEXT ART_UNREAD *toread INIT(NULL);
  2894. X            /* number of articles to be read in newsgroup */
  2895. X            /* <0 => invalid or unsubscribed newsgroup */
  2896. X#define TR_ONE ((ART_UNREAD) 1)
  2897. X#define TR_NONE ((ART_UNREAD) 0)
  2898. X#define TR_UNSUB ((ART_UNREAD) -1)
  2899. X            /* keep this one as -1, some tests use >= TR_UNSUB */
  2900. X#define TR_BOGUS ((ART_UNREAD) -2)
  2901. X#define TR_JUNK ((ART_UNREAD) -3)
  2902. X
  2903. X#ifdef USETHREADS
  2904. X#define RCCHAR(ch) ((ch) == '0' ? ':' : (ch))
  2905. X#endif
  2906. X
  2907. XEXT char *rcchar INIT(NULL); /* holds the character : or ! while spot is \0 */
  2908. XEXT char *rcnums INIT(NULL); /* offset from rcline to numbers on line */
  2909. XEXT ACT_POS *softptr INIT(NULL);
  2910. X            /* likely ptr to active file entry for newsgroup */
  2911. XEXT bool paranoid INIT(FALSE);    /* did we detect some inconsistency in .newsrc? */
  2912. XEXT int maxrcline INIT(0);    /* current maximum # of lines in .newsrc */
  2913. X
  2914. bool    rcstuff_init ANSI((void));
  2915. bool    get_ng ANSI((char *,bool_int));    /* return TRUE if newsgroup can be found or added */
  2916. NG_NUM    add_newsgroup ANSI((char *,char_int));
  2917. X#ifdef RELOCATE
  2918. X    NG_NUM    relocate_newsgroup ANSI((NG_NUM,NG_NUM));/* move newsgroup around */
  2919. X#endif
  2920. void    list_newsgroups ANSI((void));
  2921. NG_NUM    find_ng ANSI((char *));    /* return index of newsgroup */
  2922. void    cleanup_rc ANSI((void));
  2923. void    sethash ANSI((NG_NUM));
  2924. int    hash ANSI((char *));
  2925. void    newsrc_check ANSI((void));
  2926. void    write_rc ANSI((void));
  2927. void    get_old_rc ANSI((void));
  2928. END_OF_FILE
  2929. if test 2263 -ne `wc -c <'rcstuff.h'`; then
  2930.     echo shar: \"'rcstuff.h'\" unpacked with wrong size!
  2931. fi
  2932. # end of 'rcstuff.h'
  2933. fi
  2934. if test -f 'threads.c' -a "${1}" != "-c" ; then 
  2935.   echo shar: Will not clobber existing file \"'threads.c'\"
  2936. else
  2937. echo shar: Extracting \"'threads.c'\" \(2934 characters\)
  2938. sed "s/^X//" >'threads.c' <<'END_OF_FILE'
  2939. X/* $Id: threads.c,v 4.4.3.1 1991/11/22 04:12:21 davison Trn $
  2940. X**
  2941. X** $Log:    threads.c,v $
  2942. X** Revision 4.4.3.1  1991/11/22  04:12:21  davison
  2943. X** Trn Release 2.0
  2944. X** 
  2945. X*/
  2946. X
  2947. X#include "EXTERN.h"
  2948. X#include "common.h"
  2949. X#include "INTERN.h"
  2950. X#include "threads.h"
  2951. X
  2952. X#ifdef USETHREADS
  2953. X
  2954. extern char *threaddir;
  2955. X
  2956. X/* Change a newsgroup name into the name of the thread data file.  We
  2957. X** subsitute any '.'s in the group name into '/'s (unless LONG_THREAD_NAMES
  2958. X** is defined), prepend the path, and append the '/.thread' (or '.th') on to
  2959. X** the end.
  2960. X*/
  2961. char *
  2962. thread_name(group)
  2963. char *group;
  2964. X{
  2965. X    static char name_buff[MAXFILENAME];
  2966. X#ifndef LONG_THREAD_NAMES
  2967. X    char group_buff[512];
  2968. X    register char *ptr;
  2969. X
  2970. X    strcpy(group_buff, group);
  2971. X    ptr = group = group_buff;
  2972. X    while ((ptr = index(ptr, '.'))) {
  2973. X    *ptr = '/';
  2974. X    }
  2975. X#endif
  2976. X#ifdef SUFFIX
  2977. X    sprintf(name_buff, "%s/%s%s", threaddir, group, SUFFIX);
  2978. X#else
  2979. X    sprintf(name_buff, "%s/%s", threaddir, group);
  2980. X#endif
  2981. X
  2982. X    return name_buff;
  2983. X}
  2984. X
  2985. X/* Determine this machine's byte map for WORDs and LONGs.  A byte map is an
  2986. X** array of BYTEs (sizeof (WORD) or sizeof (LONG) of them) with the 0th BYTE
  2987. X** being the byte number of the high-order byte in my <type>, and so forth.
  2988. X*/
  2989. void
  2990. mybytemap(map)
  2991. BMAP *map;
  2992. X{
  2993. X    union {
  2994. X    BYTE b[sizeof (LONG)];
  2995. X    WORD w;
  2996. X    LONG l;
  2997. X    } u;
  2998. X    register BYTE *mp;
  2999. X    register int i, j;
  3000. X
  3001. X    mp = &map->w[sizeof (WORD)];
  3002. X    u.w = 1;
  3003. X    for (i = sizeof (WORD); i > 0; i--) {
  3004. X    for (j = 0; j < sizeof (WORD); j++) {
  3005. X        if (u.b[j] != 0) {
  3006. X        break;
  3007. X        }
  3008. X    }
  3009. X    if (j == sizeof (WORD)) {
  3010. X        goto bad_news;
  3011. X    }
  3012. X    *--mp = j;
  3013. X    while (u.b[j] != 0 && u.w) {
  3014. X        u.w <<= 1;
  3015. X    }
  3016. X    }
  3017. X
  3018. X    mp = &map->l[sizeof (LONG)];
  3019. X    u.l = 1;
  3020. X    for (i = sizeof (LONG); i > 0; i--) {
  3021. X    for (j = 0; j < sizeof (LONG); j++) {
  3022. X        if (u.b[j] != 0) {
  3023. X        break;
  3024. X        }
  3025. X    }
  3026. X    if (j == sizeof (LONG)) {
  3027. X      bad_news:
  3028. X        /* trouble -- set both to *something* consistent */
  3029. X        for (j = 0; j < sizeof (WORD); j++) {
  3030. X        map->w[j] = j;
  3031. X        }
  3032. X        for (j = 0; j < sizeof (LONG); j++) {
  3033. X        map->l[j] = j;
  3034. X        }
  3035. X        return;
  3036. X    }
  3037. X    *--mp = j;
  3038. X    while (u.b[j] != 0 && u.l) {
  3039. X        u.l <<= 1;
  3040. X    }
  3041. X    }
  3042. X}
  3043. X
  3044. X/* Transform each WORD's byte-ordering in a buffer of the designated length.
  3045. X*/
  3046. void
  3047. wp_bmap(buf, len)
  3048. WORD *buf;
  3049. int len;
  3050. X{
  3051. X    union {
  3052. X    BYTE b[sizeof (WORD)];
  3053. X    WORD w;
  3054. X    } in, out;
  3055. X    register int i;
  3056. X
  3057. X    if (word_same) {
  3058. X    return;
  3059. X    }
  3060. X    while (len--) {
  3061. X    in.w = *buf;
  3062. X    for (i = 0; i < sizeof (WORD); i++) {
  3063. X        out.b[my_bmap.w[i]] = in.b[mt_bmap.w[i]];
  3064. X    }
  3065. X    *buf++ = out.w;
  3066. X    }
  3067. X}
  3068. X
  3069. X/* Transform each LONG's byte-ordering in a buffer of the designated length.
  3070. X*/
  3071. void
  3072. lp_bmap(buf, len)
  3073. LONG *buf;
  3074. int len;
  3075. X{
  3076. X    union {
  3077. X    BYTE b[sizeof (LONG)];
  3078. X    LONG l;
  3079. X    } in, out;
  3080. X    register int i;
  3081. X
  3082. X    if (long_same) {
  3083. X    return;
  3084. X    }
  3085. X    while (len--) {
  3086. X    in.l = *buf;
  3087. X    for (i = 0; i < sizeof (LONG); i++) {
  3088. X        out.b[my_bmap.l[i]] = in.b[mt_bmap.l[i]];
  3089. X    }
  3090. X    *buf++ = out.l;
  3091. X    }
  3092. X}
  3093. X
  3094. X#endif /* USETHREADS */
  3095. END_OF_FILE
  3096. if test 2934 -ne `wc -c <'threads.c'`; then
  3097.     echo shar: \"'threads.c'\" unpacked with wrong size!
  3098. fi
  3099. # end of 'threads.c'
  3100. fi
  3101. echo shar: End of archive 2 \(of 13\).
  3102. cp /dev/null ark2isdone
  3103. MISSING=""
  3104. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 ; do
  3105.     if test ! -f ark${I}isdone ; then
  3106.     MISSING="${MISSING} ${I}"
  3107.     fi
  3108. done
  3109. if test "${MISSING}" = "" ; then
  3110.     echo You have unpacked all 13 archives.
  3111.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  3112. else
  3113.     echo You still need to unpack the following archives:
  3114.     echo "        " ${MISSING}
  3115. fi
  3116. ##  End of shell archive.
  3117. exit 0
  3118.